[comp.lang.lisp.x] Calling X-Lisp from C.

tony@oha.UUCP (Tony Olekshy) (01/28/91)

In message <1218@prlhp1.prl.philips.co.uk>, colers@prlhp1.prl.philips.co.uk
(Richard Cole) writes:
>
> we are trying to make a version of XLISP that can be called
> from a C program as a function call

WARNING -- the following design has not be validated, by me, yet.

Start with the following empirical result, using "(1+ 1)" as our sample c
string containing the text representation of a lisp expression.  In xlisp:

	(= 2 (eval (read (make-string-input-stream "(1+ 1)"))))

Now, start the c process with cvstring("(1+ 1)") and pass the result through
the xlisp code that implements make-string-input-stream, read, and eval. 
First, you need the code from xmkstrinput() (mainly the newustream() and
xlputc()), then you pass the result through xlread(), and give it to xleval(). 
The result will be the LVAL of the evaluated expression, so you can use things
like getstring() to pull the result back into c.

I've been planning to add this as a command line option, but I haven't had
time yet and this message has been in my to-reply-to queue for too long.
If I'm way off base, I'd be glad to know.

--
Yours etc., Tony Olekshy.       Internet: tony%oha@CS.UAlberta.CA
				  BITNET: tony%oha.uucp@UALTAMTS.BITNET
				    uucp: alberta!oha!tony
He who pretends to be either painter or engraver
without being a master of drawing is an imposter.  --Blake