-
Notifications
You must be signed in to change notification settings - Fork 437
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend infix operators with instructions for the formatter. #6072
base: infix-base
Are you sure you want to change the base?
Conversation
Looks great! I would rather have a Also, are there any forbidden characters or a length restriction? |
What would be the result in this case: let plus = (x, y) => x + y
let minus = (x, y) => x - y
@@infix.add(("馃榾", "plus"))
@@infix.add(("馃榾", "minus"))
@@infix.remove(("馃榾", "minus"))
let q = 3 馃榾 4 or let plus = (x, y) => x + y
let minus = (x, y) => x - y
@@infix.add(("馃榾", "plus"))
@@infix.add(("馃榾", "minus"))
@@infix.remove(("馃榾", "plus"))
let q = 3 馃榾 4 And would it be possible to use normal scoping rules instead of explicit remove declarations, e.g.: let plus = (x, y) => x + y
let minus = (x, y) => x - y
%%infix(("馃榾", "plus"))
let x = {
%%infix(("馃榾", "minus"))
3 馃榾 4 // 3 - 4
}
let q = 3 馃榾 4 // 3 + 4 This feels much more natural to me in a functional language. |
That's not what Btw the |
Not right now, as an initial exploration. But one could be more prescriptive. |
The result is pretty much undefined (whatever the quick implementation happens to be doing right now). Adding scope makes sense. There's a state mechanism this inserts into, and that mechanism currently does not preserve scoping. That's pretty random and not intended, but wanted to check that there are no consequences to the existing mechanism first. |
So yes scoping makes sense. And So perhaps I should remove |
428f5e5
to
3337e7e
Compare
Added per-module scope. |
02ecdce
to
837c9d1
Compare
Moving to a more basic PR without .add and .remove: #6076 |
Add support for `@@infix.add` and `@@infix.remove`.
This extends infix operators #6076 with instructions for the formatter.
The
@@infix.add
instruction tells the formatter to transform existing code, into code using infix operators.The
@@infix.remove
instruction does the opposite: tells formatter to transform code written using infix operators, into code that does not use them.Example of
add
:reformats to
Example of
.remove
:reformats to