What happened to the `..` operator?

I was trying the example from Makie for a Streamplot which involves the .. operator which is listed as an operator in the docs.

However, on Julia 1.9.4 I receive

julia> 1..42
ERROR: UndefVarError: `..` not defined
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

I remember that this code used to work on my machine some time ago.

It’s from a package: GitHub - JuliaMath/IntervalSets.jl: Interval Sets for Julia

4 Likes

Julia defines symbols that can be used as operators, but they aren’t all implemented in Base.

1 Like

Thanks! Has that moved around in the past? On this SE post the suggested package is IntervalArithmetic which gives

julia> 1..42
[1.0, 42.0]

which did not work for me

while IntervalSets.jl gives

julia> 1..42
1 .. 42

Any package can choose to define .. to mean whatever they’d like. Looks like there are eight registered packages that do so right now: JuliaHub search for .. (although with this funny search string it looks like we’re not previewing quite the correct line here — click the filename to see the larger context). If you are using more than one of them you’ll be asked to qualify which meaning you want.

4 Likes

Note that the documentation you got .. from was the Makie documentation, and Makie exports .. (re-exported from IntervalSets.jl).

When you are trying to reproduce code you find in a package’s documentation, you should probably have that package loaded.

4 Likes

Hm that seems to be the trouble - one of the packages in my workflow seems now to export the .. operator and thus the undefined behaviour.
I must have overlooked the warning that multiple packages export ...

After loading all your packages, you can do a using Makie: (..) to explicitly state that that’s the one you want.

2 Likes