Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntactic Sugar for And #40

Closed
Immortalin opened this issue Aug 6, 2019 · 3 comments
Closed

Syntactic Sugar for And #40

Immortalin opened this issue Aug 6, 2019 · 3 comments

Comments

@Immortalin
Copy link

Immortalin commented Aug 6, 2019

Can and be made infix? Postfix and is highly noisy for complex code.

@h3rald
Copy link
Owner

h3rald commented Aug 19, 2019

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?

@ceigey
Copy link

ceigey commented Sep 7, 2019

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.

@h3rald
Copy link
Owner

h3rald commented Nov 28, 2020

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants