Closed Immortalin closed 3 years ago
I understand but this is how postfix languages typically work. What concerns me is that in case of infix notation you'd probably want parenthesis for precedence in logical operators as well, right? and that wouldn't be too easy to implement in this case.
Could you provide some examples of how you'd expect this to work in min?
I've just been thinking this week about how a stack based language could handle math-friendly syntax without opening up a can of worms, by coincidence saw this issue just now, unfortunately I never came up with any clever solutions...
Apparently some lisp varieties get around the problem with infix macros. E.g. this example for Common Lisp.
In a language without macros, you could perhaps lazily evaluate a quotation for infixes. E.g. as per this example
ls (ftype "file" ==) filter '> sort
would become
ls (ftype == "file") infix filter '> sort
(then something like ls .(ftype == "file") filter '> sort
might be possible as shorthand, assuming .(___)
isn't taken).
... but that's obviously adding its own sort of noise.
This doesn't address the precedence problem at all though; just seems like a possible hacky way to introduce the functionality without changing how the language is interpreted/compiled.
Uhhh well, I may have just added an infix-dequote symbol after all: 78dad59
It lets you write things like:
((2 + 3) * 5) infix-dequote ;outputs 25
BUT of course it doesn't have any concept of operator precedence:
(2 + 3 * 5) infix-dequote ;still outputs 25
I'd have to teach it that, but I don't think I'll bother (you can use parentheses to clarify precedence anyway).
Can
and
be made infix? Postfixand
is highly noisy for complex code.