Code: Select all
import os
from subprocess import *
(rx, wx) = os.pipe()
(ra, wa) = os.pipe()
asy = Popen(['asy', '-noV', '-multline', '-q', '-inpipe=' + str(rx), '-outpipe=' + str(wa)])
fout = os.fdopen(wx, 'w')
fin = os.fdopen(ra, 'r')
fout.write("file fout = output(mode = 'pipe');\n")
fout.write("write(fout, sin(1), endl);\n") # just an example: calculate sin(1)
fout.flush()
print fin.readline() # this works, indeed!
I'd love to implement this in Lisp (since I don't see another way of doing that). However, there's much to be desired about my real-life Lisp skills, and what's more I'm not much skilled in inter-process communication. I've been reading a lot these days, and I've got a mess of descriptors, sockets, and suchlike in my head. I'd be happy if you at least point me in the right direction: usocket, iolib, implementation dependent tools...
As for the result, of course I'd like it to be portable. Or at least SBCL and CLISP. Or at least SBCL.
Any help appreciated.