Where is quote (again)?
Paul Foley
see at below
Mon Mar 11 06:16:45 EST 2002
On Sat, 09 Mar 2002 20:51:02 GMT, logistix wrote:
> I ain't no lisp expert (so please don't yell at me Paul F. ; ) ), but the
> interpreter is a read-eval-apply loop.
> 1. A statement is READ in
> 2. The arguments are EVALuated (unless short circuited by a quote)
> 3. The evaluated arguements are APPLYed to the function, result is returned
1. A form is READ in
2. The form is evaluated
3. The results are printed [CL supports multiple values]
The evaluation consists of first evaluating the arguments to
functions, but QUOTE forms are evaluated, too; its value is just its
argument, unevaluated. QUOTE is one of a small number of hard-wired
things called "special operators" that have special meaning and don't
follow the normal evaluation rules.
E.g., ignoring a few details,
def EVAL (form):
# macroexpand form here
if type(form) is not type([]):
# if it's a symbol, return its symbol-value
return form
elif form[0] is QUOTE:
if len(form) != 2:
raise SomeException
return form[1]
# other special forms here
else:
return apply(form[0], map(EVAL, form[1:]))
[Many implementations don't actually have an interpreter at all, and
implement EVAL as something more like
(defun eval (form)
(funcall (compile nil `(lambda () , at form))))
i.e., just compile a function whose body is the form in question, and
immediately execute the newly-compiled function. `(lambda () , at form)
means essentially "[LAMBDA, []] + form" in Python]
> "N Becker" <nbecker at fred.net> wrote in message
> news:1f5252d4.0203080721.3bfc5c14 at posting.google.com...
>> Back in 1999, I asked "where is quote?". I was looking for
>> a way to quote a function (delay evaluation).
>>
>> I wonder if there is anything new. It looks to me that the
>> best answer is to use lambda.
Quoting code for later evaluation with EVAL is almost guaranteed not
to be what you want, anyway. LAMBDA is the right thing.
--
Oh dear god. In case you weren't aware, "ad hominem" is not latin for
"the user of this technique is a fine debater."
-- Thomas F. Burdick
(setq reply-to
(concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))
More information about the Python-list
mailing list