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

parsing of ... with ranges #3456

Closed
mlubin opened this issue Jun 19, 2013 · 2 comments
Closed

parsing of ... with ranges #3456

mlubin opened this issue Jun 19, 2013 · 2 comments
Assignees
Labels
kind:breaking This change will break code

Comments

@mlubin
Copy link
Member

mlubin commented Jun 19, 2013

This is potentially deceptive:

julia> f(x...) = dump(x)

julia> f(1:2)
(Range1{Int64},) (1:2,)

julia> f(1:2...)
(Range1{Int64},) (1:2,)

julia> f((1:2)...)
(Int64,Int64) (1,2)

Is there a reason why the ... is ignored in the parsing of 1:2...?

@carlobaldassi
Copy link
Member

The ... is not ignored, but it's attached to 2:

julia> [2...]
1-element Int64 Array:
 2

julia> 1:2...
1:2

I suppose that the latter is because 1:2... gets translated to colon(1, 2...) and numbers are iterables which yield one value.

Se also:

julia> 1...:2
1:2

I actually don't see a reason why : shouldn't take precedence over ... when written as 1:2..., i.e. I don't see any reasonable usage of 1:(2...) (maybe if colon is overloaded on custom types? Still the usual case seems more frequent).

Maybe the precedence of these operators should be changed?

@JeffBezanson
Copy link
Sponsor Member

Yeah, this is unintentional. Seems better to parse it as (1:2)....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:breaking This change will break code
Projects
None yet
Development

No branches or pull requests

3 participants