Subject: Re: Lisp's unique feature: compiler available at run-time
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 23 Jul 2002 09:22:04 GMT
Newsgroups: comp.lang.lisp,comp.object
Message-ID: <ahj77s$aqvm0$1@fido.engr.sgi.com>
JRStern <JXSternChangeX2R@gte.net> wrote:
+---------------
| As others have said, you just build up source text in a variable,
| then Eval() the variable.
+---------------

Correction: In Common Lisp, EVAL works on Lisp *objects*, not
test strings per se. Or more precisely, if you EVAL a text string,
you only get back the string itself (since strings are self-evaluating
literal objects):

	(eval "(+ 2 3)") ==> "(+ 2 3)"

What you usually want to feed to EVAL is a *data structure* that
represents a valid Lisp program, e.g.:

	(eval (list '+ 2 3)) ==> 5

It's the READ procedure (including variants such as READ-FROM-STRING
and the READ that's an implicit part of LOAD), with all of its
programmability (see CLHS "2.1.1 Readtables") that converts source
text into Lisp data structures.

Those resulting data structures might or might not get passed to EVAL,
depending on who did the READ and why. In the following case, it does:

	(eval
	  (read-from-string
	    (coerce
	      (list #\( #\+ #\space #\2 #\space #\3 #\))
	      'string)))
	==> 5

But in other cases, the application just wants to use the resulting
data structure for its own purposes.


-Rob

-----
Rob Warnock, 30-3-510		<rpw3@sgi.com>
SGI Network Engineering		<http://www.rpw3.org/>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA

[Note: aaanalyst@sgi.com and zedwatch@sgi.com aren't for humans ]