Re: Alternative E loader

Thomas Leonard <tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]>
Newsgroups gmane.comp.lang.e.general
Organization IT Innovation
Message-ID <[email protected]>
On Fri, 2010-02-19 at 14:04 -0500, Kevin Reid wrote:
> On Feb 19, 2010, at 12:23, Thomas Leonard wrote:
[...]
> >> On Feb 19, 2010, at 10:45, Thomas Leonard wrote:
> >>
> >>> If accepted, it could also be used by rune to load the main program.
> >>> This would allow all E programs to import emaker files from the same
> >>> directory without any extra configuration (e.g. rune -cpa ...).
> >>
> >> Per capability design principles, programs should not get automatic
> >> read authority to what happens to be in the same directory.  
> >> However, a
> >> "run the program which consists of this module-directory's main entry
> >> point" or other invocation mechanism which explicitly specifies *that
> >> the directory access should exist* would be reasonable.
> >
> > OK. Though I'm not too worried about this case. If it's a single
> > script.e then it already has <file>, and using <this:...> is just a  
> > way
> > to pass the read authority to other files, as it could have done  
> > anyway.
> 
> Oh. Right. That is not an issue, yes.

For discussion, I've put up changes to do this on my "rune-this" branch:

http://gitorious.org/~tal-itinnov/repo-roscidus/it-innovation/commits/rune-this

This builds on the previous changes (adding ELoader and refactoring
eLauncher). The changes are:

- If you run "rune file.e", <this> will allow importing other E source
code from the same directory as "file.e". Files imported this way will
also get a reference to <this>.

- If you use --src or "rune -", <this> will load files from the current
directory. This is useful for interactive use.

If you run "rune file.emaker" (or use --confine), the <this> loader will
not be available.


This makes it easy to write multi-file modules without messing with
classpath. e.g.

$ cat somepath/foo.emaker  
traceln("Hello from foo!")

$ cat somepath/runetest.e 
traceln("main!")
<this:foo>

$ rune somepath/runetest.e 
=== 2010-03-12T11:44:29.078Z (Traceln.traceit:Traceln.java:90) WRN
__main: 
> main!
 : (traceln)
 @ Traceln#run(String)
 @ run/1: <.../somepath/runetest.e#:span::1:7::1:7>
=== 2010-03-12T11:44:29.282Z (Traceln.traceit:Traceln.java:90) WRN
__main$foo: 
> Hello from foo!
 : (traceln)
 @ Traceln#run(String)
 @ run/1: <.../somepath/foo.emaker#:span::1:7::1:7>


For projects that have multiple modules, each module can be given its
own <this>, to load just its own files. It's up to the main program to
wire the other modules together.


Note: this adds an extra argument to makeEvalContextAuthor.emaker. I
could add a run method with the old signature if anyone else is using
it. The only use I could see was updoc (which I changed to pass null).
Though probably updoc scripts should get a <this> as well.

Thoughts?


-- 
Dr Thomas Leonard
IT Innovation Centre
2 Venture Road
Southampton
Hampshire SO16 7NP

Tel: +44 0 23 8076 0834
Fax: +44 0 23 8076 0833
mailto:tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]
http://www.it-innovation.soton.ac.uk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.