just putting this in writing helped a lot: I'll give solution 3 a try (see 
below). I'd still love to pair with Racketeers, so let me know if u're 
interested. Unfortunately, noone here at Hacker School wants to do any Racket, 
everyone's hyped by Clojure, JavaScript and Python. Feeling so lonely :)  

----- original post -------

Anyone wants to brainstorm porting scsh to Racket? I'm having an architectural 
block here, would appreciate any help. 

I already have syntactic niceties of scsh transcribed into lower-level calls 
[github]. Deciding what those calls should be is where I'm stuck. I'll be happy 
to just spawn new processes and have them communicate for now. I hoped I could 
get away with mostly using Racket's (subprocess ..), but unfortunately it only 
works for invoking external stuff. So having a pipe like this won't work:

> (run 
>     ((| (ls) 
>         (begin . (some racket code here))
>       (some other external program here))
>     (> (current-error-port) LogFile))

Notice the (begin ..) form in the middle. (subprocess ..) is a primitive 
written in C [thx to nice people on #racket IRC for pointing it out]. If I had 
primitives like fork and exec, I could just follow along the original 
implementation or guile-scsh. Guile has access to almost full library of Posix 
syscalls, which I think were written for scsh to begin with. It seems wasteful 
to throw away all the work in Racket's port.c that basically hides the mess of 
dealing with Unix fdes from you (among other things) - its 10'000 lines of C 
code!

Right now I have three possible solutions in mind:

1 - Racket/ffi fork and exec from the C world and follow in the footsteps of 
original implementation. This means writing C, messing with Racket's ffi, 
messing with proper treatment of Unix file-descriptors with garbage collection 
in mind, etc. 

2 - with above pipe example in mind wrap the (begin ...) bit in a separate 
thread or something, spawn external stuff through calls to (subprocess ..). 
Basically do some concurrency magic [again, pointed on #racket IRC].

3 - i'm overcomplicating things. Just (make-pipe) inside (begin ..) and 
(subprocess _ pipe-in _ ..) the next external process.

I'm in EST timezone, so can pair with anyone in US (skype, facetime, ...), 
unless you find it weird, in which case email or IRC me. 

---
Vlad Kozin <vladilen.ko...@gmail.com>



____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to