Kevin Reid | 3 Jan 2006 18:49

E-on-CL / 0.8.35f compatibility patch

As discussed in

<http://www.eros-os.org/pipermail/e-lang/2005-August/010959.html>

there is a bug in 0.8.35f which prevents E-on-CL from working with  
it. For convenience, here is the fix as a patch.

If you're not using an E source distribution, you can use the 'jar'  
tool to extract the .emaker file from e.jar, and put the modified  
version into the archive.

--- esrc/org/erights/e/elang/visitors/makeConvertENode2Term.emaker~	 
2005-08-06 02:33:12.000000000 -0400
+++ esrc/org/erights/e/elang/visitors/makeConvertENode2Term.emaker	 
2005-08-10 15:52:34.000000000 -0400
 <at>  <at>  -228,7 +228,7  <at>  <at> 
                  term`[${convert(optMethods)}*]`
              }
              return term`EScript($meths,
-                                [${convert(matchers)}]*)`
+                                [${convert(matchers)}*])`
          }
          to visitEMethod(optOriginal :nullOk[ENode],

Attachment (e-0.8.35f-node-visitor.patch): application/octet-stream, 542 bytes

--

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>
(Continue reading)

Andy Dwelly | 4 Jan 2006 09:02

Comparing e and Scheme.......

Just recently I've been looking at scripting languages running on the 
JVM for web programs. Despite the religious fervour that people often 
lend to their chosen tool, I've found them all pretty much the same. 
Jython/Python, Ruby, Beanshell, and Groovy offer a similar feature set 
at various levels of stability and performance.

The two standouts are e (for reasons that are well known here) and 
Scheme. Scheme is interesting because its reliance on s-expressions 
means that source to source program transformations are easy, its 
hygenic macro system means that its syntax can be extended within 
certain well defined but handy limits, and it's primitive 
call-with-current-continuation allows new control flow structure to be 
implemented and more to the point, continuation style web scripts can be 
built.

Are there any equivalents in e ? Is there a way I could (within e) 
convert an e program to a data structure, fiddle with it, convert it 
back into a program and execute it ? Can I extend the syntax within an e 
program ? Is there some equivalent to continuations ? I've got a feeling 
that a promise might be a very close equivalent in fact but I'm not 
expert enough to see how the continuation passing style could be managed....

Andy
Kevin Reid | 4 Jan 2006 14:57

Re: Comparing e and Scheme.......

On Jan 4, 2006, at 3:02, Andy Dwelly wrote:

> Just recently I've been looking at scripting languages running on  
> the JVM for web programs.

<insert generic "'scripting' language is not a useful term" rant here>

> Despite the religious fervour that people often lend to their  
> chosen tool, I've found them all pretty much the same. Jython/ 
> Python, Ruby, Beanshell, and Groovy offer a similar feature set at  
> various levels of stability and performance.
>
> The two standouts are e (for reasons that are well known here) and  
> Scheme. Scheme is interesting because its reliance on s-expressions  
> means that source to source program transformations are easy, its  
> hygenic macro system means that its syntax can be extended within  
> certain well defined but handy limits, and it's primitive call-with- 
> current-continuation allows new control flow structure to be  
> implemented and more to the point, continuation style web scripts  
> can be built.
>
> Are there any equivalents in e ?

There is no exact equivalent to the Lisp family's s-expressions. E  
programs may be manipulated as ENode trees, and there are Term-trees  
for representing data in similar style to S-expressions, but they  
aren't the same thing (though they can be converted back and forth  
reasonably straightforwardly).

> Is there a way I could (within e) convert an e program to a data  
(Continue reading)

Steve Johnston | 15 Jan 2006 19:07
Picon

Netcat in E?

I set out to write a simple netcat like E program.  It would accept a connection on one socket, connect outbound on another, and route data from one to the other in both directions. 

It would be relatively straightforward to write the E code to use unsafe java Socket 's to poll for packets and route the data as it arrives.  This seems to fly in the face of the spirit of E, however.
Using the blocking read() methods of the InputStream doesn't achieve the goal :  forward data immediately upon it's arrival.  Immediately may be the wrong word.  The condition is forwarding a packet in one direction cannot wait until the arrival of a packet in the other direction. 

As near as I can tell the only way to get an E program to accept an arbitrary TCP connection is to use a java class.  Please correct me if I am wrong.  I was excited when I thought that I could use elib.EIO to turn the Streams I get from the Socket class into an E Stream.  But EIO does not seem to be implemented yet. 

I would appreciate commentary on the following:
1)  Can E accept arbitrary TCP connections without appealing directly to the Java/ CL libraries, even locally? I think the answer is no. 
2)  Given two connections on two sockets, can E Shuffle data between the two efficiently without polling a java class(or using java NIO)?
As near as I can tell the answer is no, without EIO.

Any help is appreciated.

Thanks in advance,
Steven Johnston

_______________________________________________
e-lang mailing list
e-lang@...
http://www.eros-os.org/mailman/listinfo/e-lang
Mark S. Miller | 15 Jan 2006 22:33

Re: Netcat in E?

Steve Johnston wrote:
> I set out to write a simple netcat like E program.  It would accept a 
> connection on one socket, connect outbound on another, and route data 
> from one to the other in both directions. 
> 
> It would be relatively straightforward to write the E code to use unsafe 
> java Socket 's to poll for packets and route the data as it arrives.  
> This seems to fly in the face of the spirit of E, however.

Correct.

> Using the blocking read() methods of the InputStream doesn't achieve the 
> goal :  forward data immediately upon it's arrival.  Immediately may be 
> the wrong word.  The condition is forwarding a packet in one direction 
> cannot wait until the arrival of a packet in the other direction. 

Correct.

> As near as I can tell the only way to get an E program to accept an 
> arbitrary TCP connection is to use a java class.  Please correct me if I
> am wrong.  I was excited when I thought that I could use elib.EIO to 
> turn the Streams I get from the Socket class into an E Stream.  But EIO 
> does not seem to be implemented yet. 

For E-on-Java, this is currently correct. OTOH, E-on-CL 
<http://homepage.mac.com/kpreid/elang/e-on-cl/> has made much progress on 
implementing EIO.

Kevin, is E-on-CL's EIO ready for writing such a netcat?

> I would appreciate commentary on the following:
> 1)  Can E accept arbitrary TCP connections without appealing directly to 
> the Java/ CL libraries, even locally? I think the answer is no. 

Correct.

> 2)  Given two connections on two sockets, can E Shuffle data between the 
> two efficiently without polling a java class(or using java NIO)?
> As near as I can tell the answer is no, without EIO.

The situation is not quite this bad. Given a Java class, like java.net.Socket, 
which blocks but is otherwise tamed, the following code shows a generic 
technique for turning blocking Java operations into non-blocking E operations.

Import and authorize a seedVat function, for running E code in new vats.

     ? def seedVat := <elang:interp.seedVatAuthor>(<unsafe>)
     # value: <seedVat>

Evaluate the E expression "<unsafe:java.net.Socket>()" in the privileged scope 
of a new vat. Returns a pair of a reference to the result of evaluating the 
expression (farSock) and the new vat (sockVat, running in its own new thread) 
in which this expression is evaluated. (The two argument form of seedVat lets 
you pass in a pre-existing vat rather than having it make a new one.)

     ? def [farSock, sockVat] := seedVat("<unsafe:java.net.Socket>()")
     # value: [<Remote Promise>, <Vat newSeedVat in <runs in newSeedVat>>]

If you now ask farSock to do a blocking operation, it will, which will block 
its own vat, and so violate the E computational model. However, so long as 
each blocking device is given its own vat/thread to block, they won't block 
each other or computation happening in normal non-blocking vats. From the 
perspective of normal non-blocking vats, they can just interact with these 
"remote" devices as if they are non-blocking devices conforming to the E 
computational model.

The following example isn't actually a blocking operation, but you get the idea:

     ? def x := farSock <- getSoTimeout()
     # value: <Remote Promise>

     ? interp.waitAtTop(x)
     # value: 0

Unfortunately, this seedVat technique is not sufficient for implementing EIO 
on top of Java streams, because of the "Preserve Immediacy" requirement at the 
bottom of <http://www.erights.org//elib/concurrency/eio/goals.html>. Instead, 
I expect that an EIO implementation for E-on-Java will wrap Java's 
non-blocking NIO operations. An NIO-based implementation should also be *much* 
more efficient, as it doesn't create a vat/thread per device.

--

-- 
Text by me above is hereby placed in the public domain

     Cheers,
     --MarkM
Kevin Reid | 17 Jan 2006 16:30

Re: Netcat in E?

On Jan 15, 2006, at 16:33, Mark S. Miller wrote:
> Steve Johnston wrote:
>> As near as I can tell the only way to get an E program to accept  
>> an arbitrary TCP connection is to use a java class.  Please  
>> correct me if I
>> am wrong.  I was excited when I thought that I could use elib.EIO  
>> to turn the Streams I get from the Socket class into an E Stream.   
>> But EIO does not seem to be implemented yet.
>
> For E-on-Java, this is currently correct. OTOH, E-on-CL <http:// 
> homepage.mac.com/kpreid/elang/e-on-cl/> has made much progress on  
> implementing EIO.
>
> Kevin, is E-on-CL's EIO ready for writing such a netcat?

Halfway. Client (connect()) sockets are possible, servers (listen())  
are not. (I've written the code to support listening, but it doesn't  
work and I haven't gotten around to finding out why, so it hasn't  
been committed yet.)

However, an old project of mine was EIO implemented on E-on-Java. I  
lost interest, but the code mostly works, though the interface for  
creating socket streams no longer matches how I think it should be done.

I have now published the source in its current state:

<http://homepage.mac.com/kpreid/2006/01-17-keio.tar.gz>

--

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>
Mark Miller | 17 Jan 2006 21:38
Picon
Gravatar

Re: Netcat in E?

On 1/17/06, Kevin Reid <kpreid@...> wrote:
> However, an old project of mine was EIO implemented on E-on-Java. I
> lost interest, but the code mostly works, though the interface for
> creating socket streams no longer matches how I think it should be done.
>
> I have now published the source in its current state:
>
> <http://homepage.mac.com/kpreid/2006/01-17-keio.tar.gz>

Very cool! Should I bundle this with E-on-Java? How compatible is this
with your EIO for E-on-CL?

What's *.DS_Store ?

--
Text by me above is hereby placed in the public domain

    Cheers,
    --MarkM
Kevin Reid | 19 Jan 2006 22:32

Re: Netcat in E?

On Jan 17, 2006, at 15:38, Mark Miller wrote:

> On 1/17/06, Kevin Reid <kpreid@...> wrote:
>> However, an old project of mine was EIO implemented on E-on-Java. I
>> lost interest, but the code mostly works, though the interface for
>> creating socket streams no longer matches how I think it should be  
>> done.
>>
>> I have now published the source in its current state:
>>
>> <http://homepage.mac.com/kpreid/2006/01-17-keio.tar.gz>
>
> Very cool! Should I bundle this with E-on-Java?

Up to you. IIRC, it contains some subtle bugs, and it doesn't have a  
proper package prefix (I own no domains).

> How compatible is this with your EIO for E-on-CL?

I don't know. I wrote both of them pretty much not looking at the  
other. They have large non-overlapping parts.

> What's *.DS_Store ?

Mac OS X metadata. Included only because I wasn't careful in creating  
the archive.

--

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>
Mark Miller | 20 Jan 2006 01:08
Picon
Gravatar

Re: Netcat in E?

On 1/19/06, Kevin Reid <kpreid@...> wrote:
> [...] it doesn't have a
> proper package prefix (I own no domains).

What about org.cubik?

> I don't know. I wrote both of them pretty much not looking at the
> other. They have large non-overlapping parts.

In that case, I won't. At some point, I expect to accept many of your
E files back into the E-on-Java distribution, at which time we'll try
to reconcile remaining differences. In the meantime, I've added the
following text to the shared download page
<http://www.erights.org/download/index.html>:

keio (link): Kevin Reid's draft implementation of EIO for E-on-Java.
    Read Kevin's announcement and more before using. I expect the
eventual official EIO
    implementation for E-on-Java will be based instead on Kevin's
implementation of EIO for
    E-on-CL.

    Keio depends on Java's NIO, which was introduced as of Java 1.4.

--
Text by me above is hereby placed in the public domain

    Cheers,
    --MarkM
Kevin Reid | 20 Jan 2006 02:18

Re: Netcat in E?

On Jan 19, 2006, at 19:08, Mark Miller wrote:
> On 1/19/06, Kevin Reid <kpreid@...> wrote:
>> [...] it doesn't have a
>> proper package prefix (I own no domains).
>
> What about org.cubik?

Owned by a friend, who I don't want to bother with a lot of little  
stuff. I do need *something* as a namespace for the miscellaneous E  
code I'm producing, but I haven't given it adequate thought at the  
moment.

>> I don't know. I wrote both of them pretty much not looking at the  
>> other. They have large non-overlapping parts.
>
> In that case, I won't. At some point, I expect to accept many of  
> your E files back into the E-on-Java distribution, at which time  
> we'll try to reconcile remaining differences.

Is there any reason not to work on this incrementally now?

As one category, here's a search for the emaker files which exist in  
both E-on-Java and E-on-CL. Most of them are simple modifications.

$ find ~/x/Projects/cl-e-clean/lib/ -name '*.emaker' |
 >   perl -ne 'chomp; s%^.*//%%; print "$_\n" if -e "/Stuff/e/src/ 
esrc/$_"'
org/erights/e/elang/cmd/controlLoopMaker.emaker
org/erights/e/elang/coord/OrderedRegionMaker.emaker
org/erights/e/elang/coord/OrderedSpaceMaker.emaker
org/erights/e/elang/interp/__makeVerbFacet.emaker
org/erights/e/elang/interp/PerlMatchMakerMaker.emaker
org/erights/e/elang/interp/require.emaker
org/erights/e/elib/sealing/makeBrand.emaker
org/erights/e/elib/slot/makeLazySlot.emaker

>     Keio depends on Java's NIO, which was introduced as of Java 1.4.

This is false. kEIO's network interface is based on blocking on  
java.io.Socket's streams in separate vats.

--

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>

Gmane