Most Julia programs use `using`, but we have both `using` and `import` 
because there are good reasons for both.

Import is does not clutter your namespace, and naming collisions for 
`using` is currently problematic (see: 
#4345<https://github.com/JuliaLang/julia/issues/4345>). 
A problem with `import` is that when packages extends functions from Base 
with new method definitions, the result is confusing (as you apparently 
found out).

Ivar

kl. 14:27:36 UTC+1 torsdag 20. februar 2014 skrev Richard Thanki følgende:
>
> Tusen Takk Ivar!
>
> A newbie misstep :) Is either of these two methods preferred?
>
>
>
>
> On Thursday, 20 February 2014 14:18:30 UTC+1, Ivar Nesje wrote:
>>
>> That was better.
>>
>> The problem is that you `import DataStructures` instead of `using 
>> DataStructures`. If you use `import` you will need to use the fully 
>> qualified name.
>>
>> The push! and pop! functions exist in Base. DataStructures extends them 
>> with new methods to work with binary heap.
>>
>> update! and top does not exist in Base, so DataStructures defines its own 
>> function witch you can access with 
>>
>>     import DataStructures
>>     DataStructures.update!()
>>
>> or
>>     using DataStructures
>>     update!()
>>
>> Ivar
>>
>> kl. 14:10:22 UTC+1 torsdag 20. februar 2014 skrev Richard Thanki følgende:
>>>
>>> here you go
>>>
>>> https://gist.github.com/lePereT/9113170<https://www.google.com/url?q=https%3A%2F%2Fgist.github.com%2FlePereT%2F9113170&sa=D&sntz=1&usg=AFQjCNGD-ENMouPU7ogCXRyDBaqZmF92vQ>
>>>
>>> ps the x was my unwise insertion in a code block :) 
>>>
>>> On Thursday, 20 February 2014 14:01:27 UTC+1, Ivar Nesje wrote:
>>>>
>>>> How does your code for using mutable_binary_minheap look? Can you post 
>>>> it (or at best a minimal failing example) to gist.github.com, or 
>>>> another place where I can find it online?
>>>>
>>>> There is no variable named x in the linked code, so the error is 
>>>> probably in your code.
>>>>
>>>> Ivar
>>>>
>>>> kl. 12:54:00 UTC+1 torsdag 20. februar 2014 skrev Richard Thanki 
>>>> følgende:
>>>>>
>>>>> Hi!
>>>>>
>>>>> I'm new to Julia and I hope to use it for an agent-based model that 
>>>>> I'm building.
>>>>>
>>>>> I've downloaded and installed the 
>>>>> DataStructures<https://github.com/JuliaLang/DataStructures.jl>package, 
>>>>> and am trying to use the mutable_binary_minheap structure. I can 
>>>>> instantiate a minheap, push to it and pop from it, but two very important 
>>>>> functions claim that they're not defined: update! and top. Both return an 
>>>>> "ERROR: x not defined".
>>>>>
>>>>> But when i look at the source 
>>>>> code<https://github.com/JuliaLang/DataStructures.jl/blob/master/src/heaps/mutable_binary_heap.jl>they
>>>>>  both seem correctly defined (the code on my machine matches that 
>>>>> online). This error is there with 0.21 as well as 0.3 pre-release.
>>>>>
>>>>

Reply via email to