10 ms·
He missed one of the earliest examples of "languages and frameworks that enable identical syntax to express computations executed in two distinct phases" - imme
by warpspin 2y ago
He missed one of the earliest examples of "languages and frameworks that enable identical syntax to express computations executed in two distinct phases" - immediate words in Forth: https://www.forth.com/starting-forth/11-forth-compiler-defining-words/ https://www.forth.com/starting-forth/11-forth-compiler-defin...
- Munksgaard 2y agoMaybe I'm missing something, but isn't Lisp the original version of this?
- warpspin 2y agoWell, Lisp macros are mentioned in a footnote at least, and yes, maybe even the oldest version of this idea.
- kragen 2y agolisp macros are probably newer than forth, but i don't know that they're newer than the words [ and ] in forth. but lisp did permit arbitrary compile-time computation from the beginning, i believe
- lispm 2y agoFEXPRs existed around 1960. Macros slightly later. MIT AI Memo 57, Timothy P. Hart, MACRO Definitions for LISP, October 1963 http://bitsavers.informatik.uni-stuttgart.de/pdf/mit/ai/aim/AIM-057.pdf http://bitsavers.informatik.uni-stuttgart.de/pdf/mit/ai/aim/...
- kragen 2y agoaha, thanks! that's definitely older than forth
- TeMPOraL 2y agoPretty much. And not just via macros. Lisp languages tend to blend together "runtime" with "load time", and in case of compiled languages, also "compile time". You can write code executing during any one, or any combination of, these phases. You can reuse code between those phases. You can interleave them at will - e.g. by loading more code at runtime, or invoking a compiler, etc.
- kragen 2y agoprobably so, yes, but forth would be #2
- JonChesterfield 2y agoLisp was also the one that taught us that interpreters and compilers for nominally the same language really need to have consistent semantics, e.g. don't lexically scope in the compiler and dynamically scope in the interpreter.
- Someone 2y agoImmediate words don’t cover the “while maintaining consistent behavior (i.e., semantics) across phases” of the definition given, do they? I think normal forth words are way closer to that. They (1) normally just do whatever their definition implies, but inside a colon definition, they (1) compile code that does whatever their definition implies. They do miss C++ constexpr (https://en.cppreference.com/w/cpp/language/constexpr https://en.cppreference.com/w/cpp/language/constexpr). I haven’t read Zig docs, but that seems highly similar to Zig’s comptime to me. (1) technically, it’s not “they” doing that themselves but whatever code processes them.
- kragen 2y agoyeah, the forth feature that actually does this is not immediate words in general, but the two immediate words [ and ], which allow you to do arbitrary ad hoc computations at compile time instead of at run time but also you can just put the code you would have put between the [ ] delimiter words into an immediate word, and call it where you would have put the [ ] block. the effect is not exactly the same but it has semantics slightly more consistent with the usual semantics because your immediate word is in fact compiled just like non-immediate words are