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

function call should take precedence over inflix operators #381

Closed
sourcevault opened this issue Apr 9, 2019 · 3 comments
Closed

function call should take precedence over inflix operators #381

sourcevault opened this issue Apr 9, 2019 · 3 comments

Comments

@sourcevault
Copy link

sourcevault commented Apr 9, 2019

I think function calls should take precedence over inflix operators in moonscript.

Currently inflix is processed first:

multi = (a) -> a*2

print (multi 1) + (multi 3) -- 8

print multi 1 + multi 3 -- 14

I agree it might break existing moonscript codebase. So the change should be made in moonscript 2.0

@RyanSquared
Copy link
Contributor

I strongly disagree with this; x y + 1 would be valid both before and after; before as a function call, after as an expression statement. If you really need precedent, use: multi(1) + multi(3).

@sourcevault
Copy link
Author

Alright, I have no problem with whatever is finally decided, I just found the change in order unexpected.

multi call 1 add multi call 3

If you think in terms of BIDMAS rules the call operator is even above the brackets, while add and subtract have the lowest precedence.

@leafo
Copy link
Owner

leafo commented Apr 11, 2019

Looks like I only replied on discord. The precedence of function calling in this scenario will not change, and will probably never change! You're welcome to fork though :)

BTW this syntax is inspired by what coffeescript does, and works the same as that.

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

No branches or pull requests

3 participants