3 ms·
The forth way of doing that is even simpler: - generate a call to a subroutine LITERAL - store the characters of the string directly after that call - pa
by Someone 7y ago
The forth way of doing that is even simpler:
- generate a call to a subroutine LITERAL
- store the characters of the string directly after that call
- pad to the ‘word’ size
LITERAL does:
- pop the return address from the call stack
- from that address, compute the address of the literal
- push it to Forth’s data stack
- adjust the return address to point beyond the literal
- push the adjusted return address
- return from subroutine
And of course, this being Forth, you can define such words yourself (https://www.forth.com/starting-forth/11-forth-compiler-defining-words/ https://www.forth.com/starting-forth/11-forth-compiler-defin... (an excellent site, by the way))
- akkartik 7y agoFor sure. I love Forth and spent a long time thinking about it [1]. I'm exploring some different trade-offs in my project, worse than Forth in some ways and hopefully better than Forth in others. [1] https://plforums.org/practice/minimal-features-required-for-an-extensible-language#post_65 https://plforums.org/practice/minimal-features-required-for-...