use Forth as your toolbox to make your own DSL
and you can go _very_ far without diving into all
those dragon books and gigabyte compilers and
toolsets.
minf...@arcor.de wrote:implement DSL's?
use Forth as your toolbox to make your own DSLFascinating!
and you can go _very_ far without diving into all
those dragon books and gigabyte compilers and
toolsets.
What is it about the Forth programming language that makes it easy to
/Roger
[It has small efficient implementations, it generally lets you get close to the hardware,
and the RPN syntax lets you define new operators that work like the built-in ones. -John]
to the hardware,[It has small efficient implementations, it generally lets you get close
built-in ones. -John]and the RPN syntax lets you define new operators that work like the
Forth comprises a _very_ simple interpreter and compiler. Both can be modified and enhanced easily to the problem domain. IOW Forth is
extensible to the core of the language while still being small and
simple enough to fit into one single person's head.
Citing its inventor Chuck Moore:
"By permitting the program to dynamically modify its control language,
we mark a qualitative change in capability. In a sense, our program
has evolved into a meta-language which we apply to the application.”
The Sun boot roms also use Forth, or something Forth-like as the
built-in control language.
[The FreeBSD boot also uses Forth for boot-time configuration. It's a nice little language but we're drifting away from compilers. -John]
So the capability in a (meta)language for compile-time execution comes into play.
Forth is only one example. TCL would be my next candidate. I don't know Seed7 but its author claims to be able to e.g. redefine and create new operators which
means new semantics.
[There was a vogue in the 1970s for extensible languages like EL1 at Harvard and IMP72 at Yale. You could add new grammar rules on the fly. What that meant was that no two programs were written in the same language and they were
unreadable and often undebuggable. OOP, which lets you add new types and semantics without changing the syntax, turned out to be a lot more useful. See https://en.wikipedia.org/wiki/Extensible_programming -John]
On Tuesday, November 15, 2022 at 1:15:04 PM UTC-8, minf...@arcor.de wrote:
Citing its inventor Chuck Moore:
"By permitting the program to dynamically modify its control language,
we mark a qualitative change in capability. In a sense, our program
has evolved into a meta-language which we apply to the application.”
PostScript is also based on an RPN language interpreter, though I
am not sure that the above quotes apply in the same way.
One that I know about PostScript, and maybe not be true for Forth,
is the bind operator.
Before def, which defines a new operator, you can bind, which binds any >operators inside the new definition to their current value. (I believe it >also optimizes them to the address of the routine, saving the time for searching
for the name in a symbol table.)
So we wrote a header with new macros, and which then redefined
def such that later macros wouldn't override them.
(I think we always called them macros, not operators, but I am not
sure by now what the right name is.)
The Sun boot roms also use Forth, or something Forth-like as the
built-in control language.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 486 |
Nodes: | 16 (2 / 14) |
Uptime: | 136:07:40 |
Calls: | 9,657 |
Calls today: | 5 |
Files: | 13,707 |
Messages: | 6,166,943 |