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

Space in array indexing causes syntax error #14853

Closed
KristofferC opened this issue Jan 29, 2016 · 3 comments
Closed

Space in array indexing causes syntax error #14853

KristofferC opened this issue Jan 29, 2016 · 3 comments

Comments

@KristofferC
Copy link
Member

This gives the following error:

julia> A = zeros(5)
       for i in 1:3
            A[2*i -1] = 10
       end
ERROR: syntax: invalid spacing in left side of indexed assignment
 in eval at ./boot.jl:267

Removing the space in front of -1 makes it work.

@simonster
Copy link
Member

The problem is that Int[2*i -1] does something different from Int[2*i-1], so the parser needs to parse these forms differently, and there's nothing special about Int vs. A at parse time. x = A[2*i -1] doesn't work either for the same reason, although perhaps that needs a better error message.

@KristofferC
Copy link
Member Author

Ah, I see. Thanks! Always thought using spaces to create matrices where kinda ugly but oh well...

@StefanKarpinski
Copy link
Member

Yes, I'd like to get rid of the space-sensitive syntax.

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