Hi,

I am trying to gain a better understanding of modules, and especially
`using` and `import`, and module redefinition.

Suppose I have

--8<---------------cut here---------------start------------->8---
module Foo

export bar, baz

function bar(x)
  :something
end

baz = 42

end
--8<---------------cut here---------------end--------------->8---

Then are the following correct?

1. I can always use Foo.bar() and Foo.baz, and define new methods to
Foo.bar, without using and import.

2. `using Foo` in a module will make all the exported names available in
the current module, except that one cannot define new methods without
prefixing function names with the module name.

3. `import` is the same as `using`, except that it allows extending
methods.

One thing that is still not clear is how module redefinition and
extension changes things. If I

julia> eval(Foo, :(baz2=9))
9
julia> eval(Foo, :(export baz2))

then baz2 is available in Main, so I thought the connection of another
module was dynamic.

But if I just redefine the module Foo with the new definitions (eg by
reloading the file), then I have to issue a `using Foo` again, before
baz2 is available. So I am clearly missing something. If this is
undefined/unintended, I can file an issue, but thought I would ask
first.

Using Julia Version 0.3.5 Commit a05f87b* (2015-01-08 22:33 UTC).

Best,

Tamas

Reply via email to