colers@prlhp1.prl.philips.co.uk (Richard Cole) (01/25/91)
Hi Folks, thanks for the email/posted responses re calling xlisp from C. In fact I had just completed a version using unnamed streams when I read the Niels Mayer's recent posting. All I did was to split the original main routine in xlisp.c into three routines, an initialise, a tidy up and exit, and an evaluate an expression routine. This latter is not a loop and simply gets its expression to evaluate from a modified version of xmkstrinput which creates an unnamed stream and stuffs a string into it, the string being the argument to the routine. I will have to look at error handling though as Niels points out. Thanks again /__) . _ /_ _ _ _ / / \ / /_ / / /_| / /_/ Richard Cole <colers@prl.philips.co.uk> AI Group Philips Research Laboratories Cross Oak Lane Redhill Surrey RH1 5HA UK -- Richard Cole | Philips Research Laboratories colers@prl.philips.co.uk | Cross Oak Lane, Redhill, Surrey, RH1 5HA, UK
mayer@hplabsz.HP.COM (Niels Mayer) (01/27/91)
In article <1223@prlhp1.prl.philips.co.uk> colers@prl.philips.co.uk writes: >In fact I had just completed a version using unnamed streams when I read >the Niels Mayer's recent posting. All I did was to split the original >main routine in xlisp.c into three routines, an initialise, a tidy up >and exit, and an evaluate an expression routine. This latter is not a >loop and simply gets its expression to evaluate from a modified version >of xmkstrinput which creates an unnamed stream and stuffs a string into >it, the string being the argument to the routine. I now recall that I originally was going to use a modified xmkstrinput() but decided to write my own specialized one because I didn't want to convert the read characters into a dynamic string and then call xmkstrinput(). Copying characters from read() into a dynamic-length string isn't very efficient, and xmkstrinput() itself is quite inefficient in that xlputc() is called on each character. So I let the unnamed stream deal with the dynamic length of the input s-expression being read. The code I posted is similar xmkstrinput() except that it effectively inlines a streamlined version of xlputc() and then optimizes by moving constant calculations outside the "foreach char in string" loop. In retrospect, I realize that I should have recommended xmkstrinput(), since my code had some usage-specific hacks attached. ------------------------------------------------------------------------------- Niels Mayer -- hplabs!mayer -- mayer@hplabs.hp.com Human-Computer Interaction Department Hewlett-Packard Laboratories Palo Alto, CA. *