http://wiki.erights.org/mediawiki/index.php?title=ELoader&feed=atom&action=historyELoader - Revision history2024-03-19T04:19:44ZRevision history for this page on the wikiMediaWiki 1.15.5-7http://wiki.erights.org/mediawiki/index.php?title=ELoader&diff=2093&oldid=prevThomasLeonard: /* Using multiple modules */2011-04-11T09:49:39Z<p><span class="autocomment">Using multiple modules</span></p>
<p><b>New page</b></p><div>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).<br />
<br />
For example, create a new directory and add two files. main.e is the main program:<br />
<br />
# main.e<br />
def makeMyObject := <this:makeMyObject><br />
def obj := makeMyObject()<br />
...<br />
<br />
makeMyObject.emaker is a support file:<br />
<br />
# makeMyObject.emaker<br />
def makeMyObject() {<br />
...<br />
}<br />
<br />
Files imported using '''<this>''' also have the loader in their environment, and can import further files using it.<br />
<br />
An ELoader also allows access to the raw files (use '''<this>.getRoot()''' to get a read-only directory object). This is useful for accessing icons, documentation, etc.<br />
<br />
= Using multiple modules =<br />
<br />
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. For example, here we have two modules. "prog" is a program that depends on a library called "libfoo".<br />
<br />
def makeTraceln := <unsafe:org.erights.e.elib.debug.makeTraceln><br />
def makeELoader := <elang:interp.ELoaderAuthor>(makeTraceln)<br />
<br />
def <libfoo> := makeELoader(<file:.../libfoo>, ["this__uriGetter" => <libfoo>], "libfoo$")<br />
def <prog> := makeELoader(<file:.../prog>, ["this__uriGetter" => <prog>, => <libfoo>], "prog$")<br />
<br />
def app := <prog:makeApplication>(...)<br />
<br />
* Within libfoo, the library can load other emakers from itself using e.g. '''<this:somefile>'''.<br />
* Within prog, a file can load other emakers from prog using e.g. '''<this:somefile>''', or from libfoo using '''<libfoo:somefile>'''.<br />
<br />
You could also wrap the '''<libfoo>''' given to prog to only expose its public API.<br />
<br />
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 '''<libfoo>'''.<br />
<br />
In future, it is expected that a separate ''injector'' library will take care of selecting and downloading modules and wiring them together.<br />
<br />
See [http://0install.net/ebox.html 0install.net's EBox demo] for a working example.<br />
<br />
= See also =<br />
<br />
* http://switchb.org/darcs/e-modules/<br />
* http://www.eros-os.org/pipermail/e-lang/2010-February/013416.html -- original discussion</div>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=ELoader&diff=4408&oldid=prevThomasLeonard: Fixed links2010-06-10T11:33:03Z<p>Fixed links</p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 11:33, 10 June 2010</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 38:</td>
<td colspan="2" class="diff-lineno">Line 38:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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 '''<libfoo>'''.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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 '''<libfoo>'''.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>In future, it is expected that a separate ''injector'' library will take care of selecting and downloading modules and wiring them together, such as 0install.net.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>In future, it is expected that a separate ''injector'' library will take care of selecting and downloading modules and wiring them together, such as <ins class="diffchange diffchange-inline">[http://</ins>0install.net <ins class="diffchange diffchange-inline">0install.net]</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= See also =</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= See also =</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* switchb.org/darcs/e-modules/</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins class="diffchange diffchange-inline">http://</ins>switchb.org/darcs/e-modules/</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* www.eros-os.org/pipermail/e-lang/2010-February/013416.html -- original discussion</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* <ins class="diffchange diffchange-inline">http://</ins>www.eros-os.org/pipermail/e-lang/2010-February/013416.html -- original discussion</div></td></tr>
<!-- diff generator: internal 2024-03-19 04:19:45 -->
</table>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=ELoader&diff=4407&oldid=prev87.194.132.141 at 18:46, 9 June 20102010-06-09T18:46:04Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 18:46, 9 June 2010</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 36:</td>
<td colspan="2" class="diff-lineno">Line 36:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>You could also wrap the '''<libfoo>''' given to prog to only expose its public API.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>You could also wrap the '''<libfoo>''' given to prog to only expose its public API.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>This avoids the need to set classpath and avoids conflicts between different packages.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>This avoids the need to set classpath and avoids conflicts between different packages<ins class="diffchange diffchange-inline">. 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 '''<libfoo>'''.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">In future, it is expected that a separate ''injector'' library will take care of selecting and downloading modules and wiring them together, such as 0install.net</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= See also =</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= See also =</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">See [http:</del>//www.eros-os.org/pipermail/e-lang/2010-February/013416.html<del class="diffchange diffchange-inline">] for details.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">* switchb.org</ins>/<ins class="diffchange diffchange-inline">darcs/e-modules</ins>/</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">* </ins>www.eros-os.org/pipermail/e-lang/2010-February/013416.html <ins class="diffchange diffchange-inline">-- original discussion</ins></div></td></tr>
<!-- diff generator: internal 2024-03-19 04:19:45 -->
</table>87.194.132.141http://wiki.erights.org/mediawiki/index.php?title=ELoader&diff=4406&oldid=prevThomasLeonard at 13:25, 9 June 20102010-06-09T13:25:51Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 13:25, 9 June 2010</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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).</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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).</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>For example:</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>For example<ins class="diffchange diffchange-inline">, create a new directory and add two files. main.e is the main program</ins>:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # main.e</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # main.e</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 7:</td>
<td colspan="2" class="diff-lineno">Line 7:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def obj := makeMyObject()</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def obj := makeMyObject()</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> ...</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> ...</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">makeMyObject.emaker is a support file:</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # makeMyObject.emaker</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # makeMyObject.emaker</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 12:</td>
<td colspan="2" class="diff-lineno">Line 14:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> ...</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> ...</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> }</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> }</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">Files imported using '''<this>''' also have the loader in their environment, and can import further files using it.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">An ELoader also allows access to the raw files (use '''<this>.getRoot()''' to get a read-only directory object). This is useful for accessing icons, documentation, etc.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Using multiple modules =</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Using multiple modules =</div></td></tr>
<!-- diff generator: internal 2024-03-19 04:19:45 -->
</table>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=ELoader&diff=4405&oldid=prevThomasLeonard at 13:22, 9 June 20102010-06-09T13:22:09Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 13:22, 9 June 2010</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 17:</td>
<td colspan="2" class="diff-lineno">Line 17:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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. For example, here we have two modules. "prog" is a program that depends on a library called "libfoo".</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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. For example, here we have two modules. "prog" is a program that depends on a library called "libfoo".</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> def makeTraceln := <unsafe:org.erights.e.elib.debug.makeTraceln></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> def makeELoader := <elang:interp.ELoaderAuthor>(makeTraceln)</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> </ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def <libfoo> := makeELoader(<file:.../libfoo>, ["this__uriGetter" => <libfoo>], "libfoo$")</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def <libfoo> := makeELoader(<file:.../libfoo>, ["this__uriGetter" => <libfoo>], "libfoo$")</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def <prog> := makeELoader(<file:.../prog>, ["this__uriGetter" => <prog>, => <libfoo>], "prog$")</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def <prog> := makeELoader(<file:.../prog>, ["this__uriGetter" => <prog>, => <libfoo>], "prog$")</div></td></tr>
<!-- diff generator: internal 2024-03-19 04:19:45 -->
</table>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=ELoader&diff=4404&oldid=prevThomasLeonard at 13:20, 9 June 20102010-06-09T13:20:57Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 13:20, 9 June 2010</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 13:</td>
<td colspan="2" class="diff-lineno">Line 13:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> }</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> }</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">If a program is made up of </del>multiple modules<del class="diffchange diffchange-inline">, 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.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">= Using </ins>multiple modules <ins class="diffchange diffchange-inline">=</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>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.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">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. For example, here we have two modules. "prog" is a program that depends on a library called "libfoo".</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> def <libfoo> := makeELoader(<file:.../libfoo>, ["this__uriGetter" => <libfoo>], "libfoo$")</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> def <prog> := makeELoader(<file:.../prog>, ["this__uriGetter" => <prog>, => <libfoo>], "prog$")</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> def app := <prog:makeApplication>(...)</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">* Within libfoo, the library can load other emakers from itself using e.g. '''<this:somefile>'''.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">* Within prog, a file can load other emakers from prog using e.g. '''<this:somefile>''', or from libfoo using '''<libfoo:somefile>'''.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">You could also wrap the '''<libfoo>''' given to prog to only expose its public API.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>This avoids the need to set classpath and avoids conflicts between different packages.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">= See also =</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>See [http://www.eros-os.org/pipermail/e-lang/2010-February/013416.html] for details.</div></td></tr>
<!-- diff generator: internal 2024-03-19 04:19:45 -->
</table>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=ELoader&diff=4403&oldid=prevThomasLeonard at 13:07, 9 June 20102010-06-09T13:07:49Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 13:07, 9 June 2010</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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).</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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).</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>For example<del class="diffchange diffchange-inline">, create a new directory and add two files. main.e is the main program</del>:</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>For example:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # main.e</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # main.e</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 7:</td>
<td colspan="2" class="diff-lineno">Line 7:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def obj := makeMyObject()</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def obj := makeMyObject()</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> ...</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> ...</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">makeMyObject.emaker is a support file:</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # makeMyObject.emaker</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # makeMyObject.emaker</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 15:</td>
<td colspan="2" class="diff-lineno">Line 13:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> }</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> }</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">Files imported using '''<this>''' also have the loader in their environment, and can import further files using it.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>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.</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">An ELoader also allows access to the raw files (use '''<this>.getRoot()''' to get a read-only directory object). This is useful for accessing icons, documentation, etc.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">= Using multiple modules =</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>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. <del class="diffchange diffchange-inline">For example, here we have two modules. "prog" is a program that depends on a library called "libfoo".</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> def makeTraceln := <unsafe:org.erights.e.elib.debug.makeTraceln></del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> def makeELoader := <elang:interp.ELoaderAuthor>(makeTraceln)</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> def <libfoo> := makeELoader(<file:.../libfoo>, ["this__uriGetter" => <libfoo>], "libfoo$")</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> def <prog> := makeELoader(<file:.../prog>, ["this__uriGetter" => <prog>, => <libfoo>], "prog$")</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> def app := <prog:makeApplication>(...)</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">* Within libfoo, the library can load other emakers from itself using e.g. '''<this:somefile>'''.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">* Within prog, a file can load other emakers from prog using e.g. '''<this:somefile>''', or from libfoo using '''<libfoo:somefile>'''.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">You could also wrap the '''<libfoo>''' given to prog to only expose its public API.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">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 '''<libfoo>'''.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">In future, it is expected that a separate ''injector'' library will take care of selecting and downloading modules and wiring them together.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">See [http://0install.net/ebox.html 0install.net's EBox demo] for a working example.</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">= See also =</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">* http://switchb</del>.<del class="diffchange diffchange-inline">org/darcs/e-modules/</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">This avoids the need to set classpath and avoids conflicts between different packages</ins>. <ins class="diffchange diffchange-inline">See [</ins>http://www.eros-os.org/pipermail/e-lang/2010-February/013416.html<ins class="diffchange diffchange-inline">] for details.</ins></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">* </del>http://www.eros-os.org/pipermail/e-lang/2010-February/013416.html <del class="diffchange diffchange-inline">-- original discussion</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<!-- diff generator: internal 2024-03-19 04:19:45 -->
</table>ThomasLeonard