Re: Lisp's QUOTE and Mathematica's "Hold"
We must find this amusing, but I'm not sure why.
Regarding eval, macros, quote in lisp and in
computer algebra systems..
JH is finally right on something.
Lisp's eval function is hardly ever used explicitly by
anyone writing lisp programs on any topic.
In the (partial) implementation of mathematica
in lisp on my web site, lisp's eval is used 0 times.
Quote is useful. It delivers constant expressions to
programs. See below.
Regarding macros: In that same collection of files,
defmacro is used mainly as a shorthand for inline coding
of function calls, or to avoid lisp's usual evaluation
mechanism in functions like plot... you don't evaluate
the 1st and 2nd args in plot(sin(x),x,-Pi, Pi).
Thinking about defmacro as "creating list
structure" is [although in some view] legitimate, that
is not how list structure needs to be created. All of
JH's maunderings about macros and how that is what
mathematica does, and therefore that is how lisp does
something, is basically wrong. Mathematica doesn't need
or use macros, and neither does a computer algebra system
written in Lisp, simulating Mathematica.
Lisp programs create list structure by using the program
called cons. Programs which use cons include list, append,
copy, and the lisp reader program.
typing '(+ a b c) or equivalently (quote (+ a b c))
instructs the lisp system to
read the symbolic expression and then evaluate it.
During the read process, the symbolic expression
(quote (+ a b c)) is consed together. The evaluation
process, considering the meaning of the quote operation,
simply returns cdr or "rest" of that list. So quote
does not create any list structure. The lisp reader
creates it. quote merely "does nothing" and that is
how most lisp programmers think of it, I expect.
Mathematica's choice of semantics, a kind of fixed-point
evaluation applied somewhat haphazardly, is not a requirement
of a computer algebra system. Macsyma has a general
rule of evaluate once, but if that doesn't work evaluate
zero times [an implicit quote in front of an unbound
variable, is an effective way of thinking about it].
Macsyma has an option "infeval" to do something similar
to Mathematica. It is hardly ever used. There are a few
exceptions to the try-to-evaluate-once; e.g. plot program
arguments.
RJF
Jon Harrop wrote:
Nathan Baum wrote:
We see again that the comparison between Release/Hold and EVAL/QUOTE is
ill-founded. It's like saying multiplication and addition are equivalent
because 2 + 2 == 2 * 2.
Yes, you are quite right. My examples that produced the right answer did so
for the wrong reason. Oh well. So Lisp's eval and quote wouldn't be very
useful for writing a CAS. What do Lispers use eval and quote for then? :-)
.
Relevant Pages
- Re: Difference between and : symbols
... lisp> ... You can inhibit evaluation with the special operator QUOTE. ... The specific thing that confused you is why ASDF functions ... But what ASDF really wants is a string. ... (comp.lang.lisp) - Re: Lisps QUOTE and Mathematicas "Hold"
... >> You can see Hold in Mathematica but not QUOTE in Lisp but isn't that more ... At least in Lisp case, the QUOTE form was evaluated and it ... However, despite the difference in method of evaluation, the results are ... (comp.lang.lisp) - Re: newbie question about quote
... > Hi I'm new to LISP. ... > "Quote may seem a bit of a foreign concept because few other languages ... This is a pain because the C compiler we are using does this, ... like a program but I want to pretend it is a data structure". ... (comp.lang.lisp) - Re: Lisp in hardware
... >> please show me a Lisp interpreter faster than Pico Lisp, ... > understanding of the power of LAMBDA, ... It just syntactially synonymous to 'quote'. ... > eventually from the reference that it has to do with properties. ... (comp.lang.lisp) - Re: Xah on Lisp
... (quote a b c) ... The language itself (i.e. the Lisp semantics) are in no way confused. ... There was simply no quote or double-quote character, ... syntactic tree made of lists and atoms, ... (comp.lang.lisp) |
|