I don't see why people won't just take the step D and Lisp do-- allowing full use of the programming language at compile time. You can execute an ordinary functions at compile-time to read a DSL from a string or read attributes (reflective metaprogramming) on your program's classes. Take the string it outputs, use mixin(), and you have code. For example: // Sort a constant declaration at Compile-Time enum a = [ 3, 1,…
The most useful values at compile time are types, so straight-up interpreting the core language at compile time is not enough. You need meta-typed named values to transport types in, and meta-functions to pass them to. Fortraith cleverly re-purposes existing features, doing some violence to language usage conventions to achieve it.
Forth implemented in Rust trait system
21–30 of 91 posts
Re: Forth implemented in Rust trait system
#22> Rust's trait system is Turing complete has anyone tried implementing rust in rust's trait system
Turing complete≠uses the syntax of your favorite programming language.
Turing completeness means using the syntax of your favorite programming language is "merely" a matter of writing the appropriate program.
What GP is proposing is completely impractical, of course. But not unreasonable, and certainly not impossible.
Re: Forth implemented in Rust trait system
#23> Rust's trait system is Turing complete has anyone tried implementing rust in rust's trait system
Turing complete≠uses the syntax of your favorite programming language.
Re: Forth implemented in Rust trait system
#24> Rust's trait system is Turing complete has anyone tried implementing rust in rust's trait system
Re: Forth implemented in Rust trait system
#25Definitely interesting, but I don't see any mention of being able to use this interactively or incremental compilation, which is what makes Forth, Forth. Forth isn't just syntax. It's an operating system and a programable programming language.
For example, in CASE ... OF ... ENDOF ... ENDCASE, the input value is consumed when OF is entered. But this means that the default result, positioned before ENDCASE, has to move the input value to the top of stack so that it can be consumed before the result. The examples in the ANS standard prefer using >R ... R> as a scratchpad for this purpose, so that any number of results may be pushed into the data stack, while the input is moved onto the result stack and then pushed back to the data stack. But the whole existence of the return stack and words that use it is a curious detail that doesn't come up if you start from an RPN calculator instead of a complete Forth system. Someone writing a RPN system in an applicative language, upon seeing this semantic, might be tempted to beef up the syntax rather than add this idiom. And in Forth this idea likely was only arrived at through the numerous iterations Moore made to achieve better expression in fewer words, since the return stack is useful everywhere.
Re: Forth implemented in Rust trait system
#26I don't see why people won't just take the step D and Lisp do-- allowing full use of the programming language at compile time. You can execute an ordinary functions at compile-time to read a DSL from a string or read attributes (reflective metaprogramming) on your program's classes. Take the string it outputs, use mixin(), and you have code. For example: // Sort a constant declaration at Compile-Time enum a = [ 3, 1,…
When you need to run an unbounded program each time you want to provide real time feedback, like type inference or in Rust case lifetime inference, you make the language tooling much less simple and accessible.
Re: Forth implemented in Rust trait system
#27Re: Forth implemented in Rust trait system
#28I don't see why people won't just take the step D and Lisp do-- allowing full use of the programming language at compile time. You can execute an ordinary functions at compile-time to read a DSL from a string or read attributes (reflective metaprogramming) on your program's classes. Take the string it outputs, use mixin(), and you have code. For example: // Sort a constant declaration at Compile-Time enum a = [ 3, 1,…
One issue not yet mentioned with Turing complete language at compile is that it makes tooling and IDE integration much more difficult. When you need to run an unbounded program each time you want to provide real time feedback, like type inference or in Rust case lifetime inference, you make the language tooling much less simple and accessible.
How so?
> When you need to run an unbounded program
How is a program that provably terminates but takes 2 years to finish any better for compile-time computation? You want timeouts in either case.
Re: Forth implemented in Rust trait system
#29Earlier quoted context omitted.
Turing complete≠uses the syntax of your favorite programming language.
Any Turing-complete system can do anything a general computer can do, which includes compiling your favorite programming language.
Re: Forth implemented in Rust trait system
#30I don't see why people won't just take the step D and Lisp do-- allowing full use of the programming language at compile time. You can execute an ordinary functions at compile-time to read a DSL from a string or read attributes (reflective metaprogramming) on your program's classes. Take the string it outputs, use mixin(), and you have code. For example: // Sort a constant declaration at Compile-Time enum a = [ 3, 1,…
In addition C++ has constexpr which marks an expression to be evaluated at compile-time.