-
Notifications
You must be signed in to change notification settings - Fork 23
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
Make (fn)expr syntax behave like a unary operation #415
Comments
|
To me what's inconsistent is the way spacing is ignored here, which is different from the way spaces are treated in other forms of function invocation: echo `$` 2 + 1 # prints 3
# echo $2 + 1 # error
echo(2, 1) # prints 21
echo (2, 1) # prints (2, 1)
In terms of real benefit, this is a syntactical proposal, so it's similar to the benefit of the command syntax: why not just use The "gain" I want from this is to define custom operators that are words (like the built-in |
Just adding a reference to my not-so-popular C/C++ interop library here that could take advantage of this feature, for documentation. |
Current behavior
There is a variant of the Nim command syntax that looks like this:
which expands to
I use this syntax to call unary "operator-like" procs. However, this does not actually behave like an operator. For example:
Proposed behavior
I propose the following behavior:
The difference is that the current behavior expands the call to
x2(2 + 1)
, and the desired behavior would expand the call tox2(2) + 1
instead.Future considerations
Perhaps this could be expanded to allow syntax like
2 (x) 2
to expand tox(2, 2)
, which is similar to Haskell's use of backticks to achieve the same effect.The text was updated successfully, but these errors were encountered: