,---------------. | Contributions | `---------------´ ,------------------------------------------ | 2024-01-06 15:25:11 lmr wrote: | example - "make the user input device the input source" | see: https://forth-standard.org/standard/core/QUIT#contribution-330 `------------------------------------------ Since `QUIT` is bound to reset the input source, what's a "clean" way to handle, say, command-line arguments (like `-e` or file arguments in Gforth)? Of course there are plenty of hacks to come up with. ,---------. | Replies | `---------´ ,------------------------------------------ | 2024-01-06 07:34:58 AntonErtl replies: | requestClarification - throw code for compiling outside a definition | see: https://forth-standard.org/standard/core/COMPILEComma#reply-1167 `------------------------------------------ There is no established throw code for compiling outside a colon definition, so you can choose a system-specific one, if you want to throw an error (most systems don't). Concerning `state`, the existence of '[' and ']' means that `state @` does not tell you at all whether you are inside a colon definition. E.g. ```` : myliteral postpone literal ; immediate \ myliteral has interpretation semantics : mycompile, compile, ; \ mycompile, has interpretation semantics : test [ 1 myliteral ] \ compiling inside a colon definition in interpret state [ ' + mycompile, ] \ compiling inside a colon definition in interpret state ; ] + [ \ compiling outside a colon definition in compile state ```` Everything but the last line is a standard program, the last line is non-standard. ,------------------------------------------ | 2024-01-06 07:54:21 AntonErtl replies: | requestClarification - are colon-defs supposed to be compiled in data space? | see: https://forth-standard.org/standard/core/Colon#reply-1168 `------------------------------------------ I don't find it written clearly enough in the document (Chapter 3 is what I looked at), that's why I leave this request open; in particular, the document says very little about code space and does not say that `compile,` allocates in code space or that the compilation semantics of various words allocate in code space. Anyway, the intention is that the current definition and the stuff that is appended to it lives in code space, except the header which lives in name space (which, as has been noted, is in conflict with he usual meaning of "name space" in programming languages). Both name space and code space may be interleaved with each other and with data space, but they can also be separate. Traditionally, they are interleaved, but for a native-code system I recommend separating out at least the code space, because writing to data close to code causes serious performance penalties (I measured 400 cycles per `!` at one point).