ELoader
From Erights
(Difference between revisions)
(→Using multiple modules) |
|||
Line 1: | Line 1: | ||
When you run a .e or (.updoc) file, it is given a loader called '''<this>''' which can be used to import .emaker files from the same directory (or from a sub-directory). | When you run a .e or (.updoc) file, it is given a loader called '''<this>''' which can be used to import .emaker files from the same directory (or from a sub-directory). | ||
- | For example | + | For example: |
# main.e | # main.e | ||
Line 7: | Line 7: | ||
def obj := makeMyObject() | def obj := makeMyObject() | ||
... | ... | ||
- | |||
- | |||
# makeMyObject.emaker | # makeMyObject.emaker | ||
Line 15: | Line 13: | ||
} | } | ||
- | + | If a program is made up of multiple modules, a separate loader can be created for each one. Each module is given its own loader as '''<this>''', as well as loaders for its dependencies. | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | If a program is made up of multiple modules, a separate loader can be created for each one. Each module is given its own loader as '''<this>''', as well as loaders for its dependencies. | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | This avoids the need to set classpath and avoids conflicts between different packages. See [http://www.eros-os.org/pipermail/e-lang/2010-February/013416.html] for details. | |
- | + |
Revision as of 13:07, 9 June 2010
When you run a .e or (.updoc) file, it is given a loader called <this> which can be used to import .emaker files from the same directory (or from a sub-directory).
For example:
# main.e def makeMyObject := <this:makeMyObject> def obj := makeMyObject() ...
# makeMyObject.emaker def makeMyObject() { ... }
If a program is made up of multiple modules, a separate loader can be created for each one. Each module is given its own loader as <this>, as well as loaders for its dependencies.
This avoids the need to set classpath and avoids conflicts between different packages. See [1] for details.