|
|
|
|
|
by klibertp
3862 days ago
|
|
If you take a look at my reply to TazeTSchnitzel you'll see that I "solved" (I think? at least tried to) this problem with indentation (generally whitespace. You can delimit expressions in many ways. And in Forth case, you can very easily define your own delimiters: : [ ;
: ] ;
which should make you able to write: [ [ 1 2 + ] [ 3 4 + ] * ] .
21 ok
(tested with gforth and works [EDIT: but of course breaks Forth! Both [ and ] are already defined, so in practice you'd rather choose another chars])I mean, there is no rule saying that postfix notation cannot provide grouping constructs. I still fail to see a fundamental difference here :) BTW, it's not going as fast as I'd like, but I managed to parse TXR man page and use it for displaying docs along auto-completion: https://github.com/piotrklibert/txr-mode/blob/master/screen.... I think I'll be able to find some time this weekend (or next weekend) to clean up the code and make it usable for others as well :) |
|
If I already know that the code is correct and properly indented, then it helps the readability.
> And in Forth case, you can very easily define your own delimiters:
Those delimiters do nothing but occupy interpreter cycles. Hopefully they get recognized as noops and optimized away by a Forth compiler.
The machine will accept garbage like:
The fake syntax you've created is there is sort of like a cargo cult airplane made out of bamboo sticks and palm leaves. It has some value as an annotation of correct code, that is all. It could be a useful annotation tool in the process of verifying a piece of code and convincing myself that it's correct. Forth should have these markers built-in so they don't have to be defined as words, and it should check their pairing and nesting. (A syntax highlighting engine can be taught to do that, of course.)