Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm out of time to continue work on this right now, so thought I'd post my progress so far for comments.
and
/or
/not
via parse tree and parenthesization, effectively just below&&
/||
/!
not
in all cases (fixes not operator #287)coffeeAndOr
restores CoffeeScript's precedence forand
/or
(same as&&
/||
)coffeeNot
restores CoffeeScript's precedence fornot
(same as!
)I still need to fix a few tests (related to custom operators) and add actual tests, but you can see intended use in the added documentation.
Possible items to discuss:
coffeeAndOr
andcoffeeAndOrNot
. Partly hampered by existingcoffeeNot
here, but not sure what's best.and
/or
/not
good (by default)?not x == y
→not (x == y)
as in Python but not CoffeeScript?a || b and c || d
→(a || b) && (c || d)
is reasonable because, if you're mixing styles of operators, you probably expect something to happen. If you stick to one or the other, there's nothing surprising.xor
is not yet low-precedence, but it already didn't mix with&&
/||
so not sure what's best... (This is also harder to fix.)operator
s be processed at regular or low precedence? Low precedence might make sense given that they're also words (currently), but on the other hand we're not changing precedence of word operators likeinstanceof
so I'm not sure.