3 ms·
The point of homoiconocity is that your macro language is your language. And your data structure language is your language. As well as your AST language. They a
by choeger 7y ago
The point of homoiconocity is that your macro language is your language. And your data structure language is your language. As well as your AST language. They are all the same.
So the author is right about observing that "intermediate ast" and "ast" share the same concrete syntax and macros transform one into the other. But macros are also defined in that language. Furthermore the output of your program is definitely in that language.
- hinkley 7y agoThere are two features of Jai I hope turn up in other languages. I'm fascinated by the 'struct of arrays' data pattern (columnar vs row-oriented storage, in effect), but also the ability to declare functions that run at compile time instead of run time, instead of macros.
- pcwalton 7y ago> declare functions that run at compile time instead of run time, instead of macros. Lots of languages have this, including C++.
- tekknolagi 7y agoAnd Zig!
- thethirdone 7y agoJai does it to a degree that is certainly not common. C++ in particular only has true guaranteed compile time execution for constexpr functions in static_asserts and a few other small cases. Jai on the other hand can do pretty much anything at compile time.
- unlinked_dll 7y agoconstexpr is Turing complete and it’s only limit is recursion depth of the compiler, which can be changed. And as of C++17/20 some of the weird stuff like not using conditionals and such isn’t present anymore. Also if you’re a masochist, the template system is Turing complete.
- thethirdone 7y agoI was not talking about the turing completeness of constexpr. There are only a few contexts in which constexpr functions are guaranteed to be evaluated at compile-time. This contrasts Jai's compile time only functions. Additionally, Jai can perform arbitrary IO at compile-time which is simply not possible with c++. One of the early demos had a program which played a videogame at compile-time.
- spc476 7y agoThat's something Forth can do. It's how the language is extended.
- TeMPOraL 7y ago> also the ability to declare functions that run at compile time instead of run time, instead of macros Lisp macros are such functions. But you can also declare regular functions to be compiled around macroexpansion time, which makes them available to call during macro expansion. You can use the same functions during macroexpansion/compiling and runtime too, and you can compile new functions at runtime.