-
Notifications
You must be signed in to change notification settings - Fork 125
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
Why doesn't OPA syntax allow optional parenthesis when functions accept a single argument? #28
Comments
I assume you're referring to the new syntax of Opa (as we have two variants of the syntax). Quick explanation would be: this syntax is inspired and intended to stay close to JavaScript and that means parenthesis for function calls. |
I was actually referring to the more concise syntax. I discussed this with you on the forum.
would call someFunc with three parameters, whereas:
calls anotherFunc with a single parameter that happens to be a tuple. Here's the exact proposal I had on the web forum: Before my proposal:
After my proposal:
I felt this was clearly much cleaner. I'll continue the discussion there. |
The syntax is nice, however we had enough recent focus on syntax to implement it now as:
But you can add your own syntax to Opa as the mechanism to select a given parser is already in the compiler. |
In SML, all functions take a single argument that may be a tuple (which gives us the standard f(x,y,z) notation).
Furthermore, if I recall correctly, all functions are actually pattern matching their tuple arguments such as:
fn 0 => 0
| n => 1
This seems like a really elegant way to model function parameters. Why does OPA not adopt this, and might is the community open to adopting the convention?
The parenthesis-free single argument syntax makes named parameters very elegant as well.
The text was updated successfully, but these errors were encountered: