ELoader

When you run a .e or (.updoc) file, it is given a loader called   which can be used to import .emaker files from the same directory (or from a sub-directory).

For example, create a new directory and add two files. main.e is the main program:

# main.e def makeMyObject :=  def obj := makeMyObject ...

makeMyObject.emaker is a support file:

# makeMyObject.emaker def makeMyObject { ... }

Files imported using   also have the loader in their environment, and can import further files using it.

An ELoader also allows access to the raw files (use  .getRoot to get a read-only directory object). This is useful for accessing icons, documentation, etc.

= Using multiple modules =

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  , as well as loaders for its dependencies. For example, here we have two modules. "prog" is a program that depends on a library called "libfoo".

def makeTraceln :=  def makeELoader := (makeTraceln) def := makeELoader(, ["this__uriGetter" => ], "libfoo$") def := makeELoader(, ["this__uriGetter" =>, => ], "prog$") def app := (...)


 * Within libfoo, the library can load other emakers from itself using e.g. .
 * Within prog, a file can load other emakers from prog using e.g. , or from libfoo using .

You could also wrap the   given to prog to only expose its public API.

This avoids the need to set classpath and avoids conflicts between different packages. For example, you could depend on two libraries which, internally, require different versions of libfoo. Each library would see the correct version of libfoo as  .

In future, it is expected that a separate injector library will take care of selecting and downloading modules and wiring them together.

See 0install.net's EBox demo for a working example.

= See also =


 * http://switchb.org/darcs/e-modules/
 * http://www.eros-os.org/pipermail/e-lang/2010-February/013416.html -- original discussion