[gambit-list] Target language REPL

Bob Coleman bobcolem at yahoo.com
Tue Nov 10 22:41:10 EST 2015


I'll first lay out a sample of this in Python 2.7, since that's what I'm most familiar with.  I think we'll be able to use the built in asyncore or select modules to handle sockets, but I don't believe asynchronous file I/O is supported on Windows (posix only) without an extension.  I will look into this deeper and see if I can find a work around.
 


     On Monday, November 9, 2015 3:14 PM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
   

 Nice to hear you want to help!  To be maximaly useful, asynchronous I/O has to be implemented so that threads waiting for I/O don’t block other threads.

So the first step is to figure out how to do asynchronous I/O in JavaScript and Python (and PHP, etc).  For JavaScript this will be different in the browser, where the only async I/O really is through XMLHttpRequest, and server-side JavaScript, a.k.a. node.js .

Basically, for each source/sink of I/O, there needs to be an “open” method (for example, opening a file, or network connection, or pipe, etc).  This has to return some handle to be passed to a “read”/“write” method with a buffer of bytes.  These methods need to return the number of bytes actually transferred, if the I/O can be done right away, or some code (say -1) if it is necessary to try again later.  A callback specified when the “open” method was called is called when the operation should be tried again.

Moreover, for implementing preemptive threads, there needs to be a way to set a heartbeat timer that calls a callback at regular intervals (1ms to 20ms range, configurable).  For example, a wrapper around setTimeout could be used for client-side JS.

I could dig through the docs of Python and client-side and server-side JS to see what is available, but if you could look into this that would be helpful.

Marc


> On Nov 9, 2015, at 2:11 PM, Bob Coleman <bobcolem at yahoo.com> wrote:
> 
> Marc -
> 
> I am not experienced with Gambit internals, but I am interested in using green threads in JavaScript and Python using the universal backend.  Let me know what I can do to help.
> 
> Thanks,
> Bob
> 
> 
> 
> 
> On Wednesday, November 4, 2015 10:30 PM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
> 
> 
> Feature-full green threads (as in Gambit-C) are not currently supported by the universal backend, but they are on the TODO and definitely doable.
> 
> To get this moving faster, I’d need some help from people interested in specific targets of the universal backend.  So if you are interested in JavaScript, PHP, Python, Ruby, Java please let me know.
> 
> Marc
> 
> > On Nov 3, 2015, at 11:09 PM, Adam <adam.mlmb at gmail.com> wrote:
> > 
> > 2015-11-04 12:05 GMT+08:00 Marc Feeley <feeley at iro.umontreal.ca>:
> > Eval is implemented, but I/O is currently very limited (only println is usable).  So the REPL does not currently work.
> > 
> > For your second question, you can use
> > 
> > (##inline-host-declaration "print('hello');”)
> > 
> > or
> > 
> > (##inline-host-statement "print(@1@);" "hello")
> > 
> > Someone could implement a REPL specific to the respective language and target environment.
> > 
> > 
> > 
> > Hm. Are there green threads?
> > 
> 
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
> 
> 

_______________________________________________
Gambit-list mailing list
Gambit-list at iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20151111/656a01f7/attachment.htm>


More information about the Gambit-list mailing list