John Flockton
11/30/2024, 2:09 PMMariano Guerra
Alex North
12/20/2024, 8:46 AMBeni Cherniavsky-Paskin
02/24/2025, 7:05 PMeval
. it's part of a longer video on one-API=multi-representation dualities across several languages.)
So while the code for control structures like if
or proc
may never say so explicitly, in practice it ends up slicing strings into something quite akin to AST tree, with parts converted to bytecode on-demand. 🪄Beni Cherniavsky-Paskin
02/24/2025, 7:09 PM( ... )
is comments, implemented by (
word eating up and discarding stdin until it meets )
character.
And : NAME word1 word2... ;
is word definition, eating up single NAME from stdin, allocating its entry-to-be-built in dictionary, then toggling main loop from "interepreter" to "compile" mode where following words are appended to the dictionary entry not executed — unless they're marked "immediate" for special handling.
- ;
is immediate word that wraps up the dictionary entry and toggles main loop back to "interpreter" mode.
- IF
, THEN
etc. are immediate words that take notice of addresses and later fixup some pointers to build up conditional, loops, etc. in a manner similar to assembly language.
---
Assemblers could answer your question in similar spirit (mostly flat 1:1 mapping to output, with some fixups), except most assemblers are not interpreted.Beni Cherniavsky-Paskin
02/24/2025, 7:19 PMBeni Cherniavsky-Paskin
02/24/2025, 7:41 PM... PDP-11 with a 64K-byte store. The single-pass strategy of our Pascal compilers could not be adopted; a multipass approach was unavoidable in view of the small memory. ...
The first Modula-2 compiler, written by K. van Le in 1977 consisted of 7 passes, each generating sequential output written onto the 2M-byte disk.IIUC what he means is multi-pass allows you to reduce RAM occupied by compiler code by loading one pass' code at a time, leaving more RAM for data (plus data can be streamed from/to disk). Funnily, similar reason also motivated Unix "do one thing" + pipes design 😄