Parsing of multiple `..`

Why does this parse,

julia> :(a .. b)
:(a .. b)

but this does not,

julia> :(a .. b .. c)
ERROR: ParseError:
# Error @ REPL[31]:1:10
:(a .. b .. c)
#        └──┘ ── Expected `)`

?

1 Like

What is .. supposed to be, from your point of view?

It’s just a binary operator that I might overload, and it would be nice if it parsed like most binary operators.

julia> .. ERROR: UndefVarError: `..` not defined
How do you come to the conclusion that it is a binary operator?

julia> ..(a, b) = a + b
.. (generic function with 1 method)

julia> 2 .. 3
5

It’s used plenty. e.g. IntervalSets

I think it’s because .. is parsed with the same precedence as :, but : is parsed strangely for multiple arguments, and probably the special-casing messes up ...

Seems like it should be fixed.

1 Like