2 ms·
I did have a recent-ish use for something like this. The 2006 ICFP contest, which was awesome, took the form of a virtual-machine image you had to write an emul
by abecedarius 15y ago
I did have a recent-ish use for something like this. The 2006 ICFP contest, which was awesome, took the form of a virtual-machine image you had to write an emulator for in order to get at the problems. The image was a self-extracting compressed executable. After the contest, we had to submit our source code. For kicks, I made a self-extracting compressed executable generator at the last minute so we could submit our stuff in the same form as the contest image itself. To make this, I needed an assembler for their VM; I made a Forth DSL just like the OP here.
Russell O'Connor was working separately on a DOS-like shell to wrap around my compressor. He needed an assembler too, and wrote his as a Haskell DSL which he later expanded and wrote up in http://www.haskell.org/wikiupload/1/14/TMR-Issue6.pdf http://www.haskell.org/wikiupload/1/14/TMR-Issue6.pdf
(Just one assembler might have been sensible, but we had to make this submission in a few hours overnight after 3 days of contest hacking and weren't up to more than minimal effort on coordinating.)
For assembler coding Forth syntax really is no worse than Lisp-syntax assembler -- I got pretty comfortable using it in practice back in the day. And as Kragen notes, the underlying Forth system is more powerful than a macro assembler. (I'd agree that Forth is not a comfy general-purpose language by modern standards.)