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

Mutating functions as keyword arguments (yet more parser space sensitivity) #8020

Closed
timholy opened this issue Aug 16, 2014 · 4 comments
Closed

Comments

@timholy
Copy link
Member

timholy commented Aug 16, 2014

I doubt there's anything to be done here, but just FYI here's a fun way to play head games with the parser:

julia> mysum(A; transform! = identity!) = sum(transform!(A))
mysum (generic function with 1 method)

julia> mysum(A; transform!=identity!) = sum(transform!(A))
ERROR: syntax: invalid keyword argument syntax "transform!=identity!" (expected assignment)

The issue is that != is being parsed as not-equals.

@JeffBezanson
Copy link
Member

Yes, a!=b is ambiguous, and we have to resolve it in favor of !=, since comparing values is much more common than identifier names with !.

@johnmyleswhite
Copy link
Member

I know I've said this before and people might hate hearing me rant again, but we probably should just enforce spaces between operators and operands. We have enough places where the language allows an ambiguity between the ends of identifiers and the start of operators that people are almost certainly going to keep tripping on these issues indefinitely far into the future.

@timholy
Copy link
Member Author

timholy commented Aug 16, 2014

Given that the error message is already pretty good, I'll close this.

The space around operators might be a good way to go, but I do fear how much it might cause some of my more complicated calculations to grpw.

@timholy timholy closed this as completed Aug 16, 2014
@tkelman
Copy link
Contributor

tkelman commented Aug 16, 2014

There's also the issue that whitespace is an operator in the case of horizontal concatenation, which maybe just maybe could get figured out and changed as part of the great breaking array reshuffle of 0.4. If only keyboards had a few more delimiters available.

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

4 participants