I happen to make a silly mistake - to create a type which has the name of the module it is in. Suppose that I want to export that type X
from my package X
:
module X
export X
export .X
export X.X
type X end
end
First would give me:
ERROR: LoadError: LoadError: invalid redefinition of constant X
Second:
ERROR: LoadError: LoadError: syntax: invalid identifier name "."
Third:
ERROR: LoadError: LoadError: syntax: extra token "." after end of expression
is there a valid syntax to solve my export problem?
P.S. I know that I could just change name for module/type.
To load a module from a package, the statement using ModuleName can be used. To load a module from a locally defined module, a dot needs to be added before the module name like using . ModuleName .
My guess based on reading the docs: using is used to bring another module into the name-space of the current module. import is used to bring specific types/functions/variables from other modules into the name-space of the current module.
Julia has two mechanisms for loading code: Code inclusion: e.g. include("source. jl") . Inclusion allows you to split a single program across multiple source files.
As Tom Breloff said, there is the well-followed practice for naming packages that implement a new type. If your package exports a type that supports very fast operations on very small strings, and that type is named FastString
, the recommended package name is FastStrings.jl
.
Julia package names include the .jl
suffix .. so should yours. For projects that pull multiple packages together under one umbrella, the project name may forgo the trailing .jl
; the packages it brings together should end with .jl
.
Some guidelines for naming packages are gathered here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With