Standard modules and paths

The code of Julia packages (also called libraries) is contained in a module, whose name starts with an uppercase letter by convention like this:

   # see the code in Chapter 6\modules.jl
module Package1
# code
end

This serves to separate all its definitions from those in the other modules, so that no name conflicts occur. Name conflicts are solved by qualifying the function by the module name. For example, the packages Winston and Gadfly both contain a function plot. If needed these two versions in the same script, we would write this as follows:

import Winston
import Gadfly
Winston.plot(rand(4))
Gadfly.plot(x=[1:10], y=rand(10))

All variables defined in the global scope are automatically added to the Main module. Thus, when ...

Get Julia: High Performance Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.