Modules


In [18]:
workspace()
module English

greeting()="Hello"
farewell() ="Goodbye!"

export greeting

end


Out[18]:
English

In [15]:
English.greeting()


Out[15]:
"Hello"

In [16]:
using English
greeting()


Out[16]:
"Hello"

In [17]:
# If something is not exported it will not automatically be available in the global namespace
farewell()


UndefVarError: farewell not defined

In [22]:
# it’s still possible to import into the global namespace functions which have not been exported
import English.farewell
farewell()


Out[22]:
"Goodbye!"

In [ ]: