3 ms·
Because functionname first would cause it to execute the function on whatever is on top of the stack. Most stack languages i've seen have the occasional bit of
by Avshalom 8y ago
Because functionname first would cause it to execute the function on whatever is on top of the stack.
Most stack languages i've seen have the occasional bit of prefix hanging around things like definitions or flow control.
- camtarn 8y agoAh, interesting. And I guess it's easier to make it prefix than to require the function name be a string or symbol. Yeah, I noticed that Fif uses prefix for function defs, but I figured that might be a pragmatic decision.
- Avshalom 8y agoYeah, Forth for instance has : Function (comment) function body ; The colon, name and stack comment are all in prefix position. But in an interpreted environment you could maybe swap the semicolon to prefix and the name to postfix but you're still stuck with some prefix token to prevent execution. Forth also has Bool if code else code which is essentially prefix. But it boils down to the same reason, you need some prefix to delay execution anyway. From a sort of conceptual level this is all fine anyway. A big part of stack languages is how they lead to a data flow sort of programming rather than some fundamentalist belief in postfix syntax. So when there is a language construct that doesn't benefit-from/contribute-to that data flow style people choose syntax they find comfortable or readable which is sometimes prefix or even infix.