🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.lisp.x
Article #258

Re: Calling XLISP from C - problem solved

#258
From: Niels Mayer
Date: Sun, 27 Jan 1991 04:33
30 lines
2118 bytes
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.
				   *
Technical Details
Message-ID: <6511@hplabsz.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hplabsz!mayer
References: <1223@prlhp1.prl.philips.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hplabsz!mayer
From: mayer@hplabsz.HP.COM (Niels Mayer)
Newsgroups: comp.lang.lisp.x
Subject: Re: Calling XLISP from C - problem solved
Message-ID: <6511@hplabsz.HP.COM>
Date: 27 Jan 91 04:33:26 GMT
References: <1223@prlhp1.prl.philips.co.uk>
Reply-To: mayer@hplabs.hp.com (Niels Mayer)
Organization: Hewlett-Packard Labs, Software & Systems Lab, Palo Alto, CA.
Lines: 30