Julia: ERROR: Module Collections not found in current path.

Created on 17 Oct 2016  路  8Comments  路  Source: JuliaLang/julia

In Julia v0.5 I can do:

Q = Collections.PriorityQueue()

but I cannot load the module:

using Collections

ERROR: ArgumentError: Module Collections not found in current path.
Run Pkg.add("Collections") to install the Collections package.
in require(::Symbol) at ./loading.jl:365

error handling

All 8 comments

I believe this is intentional. The error message could be better though.

@yuyichao why is not good idea to allow the using Collections statement? Actually I wonder why these collections aren't part of Base, these data structures are at the core of many algorithms.

why is not good idea to allow the using Collections statement?

Use using Base.Collections

Actually I wonder why these collections aren't part of Base, these data structures are at the core of many algorithms.

They are.

Sorry, reformulating my question: why are they not rightly available like Array() or Dict()? I would say that PriorityQueue could be in the global namespace.

Well, using .Collections works also, could it check that

isdefined(current_module(), :AttemptedName) && isa(current_module().AttemptedName, Module)

and add using .AttemptedName to the suggestions if so?

why are they not rightly available like Array() or Dict()? I would say that PriorityQueue could be in the global namespace.

Because we cannot put everything anyone ever find use full to be in global namespace. This might even be a good candidate to be moved out if it is not used in base.

This might even be a good candidate to be moved out if it is not used in base.

Ref https://github.com/JuliaLang/julia/issues/18497

using X always looks for X in the root namespace. We probably decided to do that so that name conflicts don't block loading a package entirely; they can only force you to add more qualifiers to names.

The other side of this is that Base exports Collections, which it arguably should not do. That might be changed with #5155.

Was this page helpful?
0 / 5 - 0 ratings