[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why quote?



1. Prolog does not have evaluation of function terms in its semantics.
All terms are what a Lisper might say always quoted.  The counterpart
of the problem for Prolog is how to introduce evaluated terms.
Since it feasible to write term rewrite rules (albeit only directional ones)
some form of evaluation can be introduced, producing various degrees
of partial and lazy evaluation methods.  But, there would be questions
similar to that of quoting, on under what circumstances what terms
will be evaluated.

2. It is true but somewhat misleading to say that Lambda-calculus has no
quoting.
(a) pure Lambda-calculus has no data structures; one can simulate data
structures by using closures in much the same way a cons-cell is defined
(in A&S book but also many other places) by a closure that returns its
first or second argument.  If one wants not simulated data structures,
but a machine-dependent real data structures (or at least dependent upon
some architectural feature such as dereferencing of pointers), one has to
introduce quotation. 
(b) simulated data structures will also introduce the confusion of quoting,
(car (lambda () a)) will be an irreducible expression; Scheme will generate
an error.

3. In Lisp implementations, since functions are called by value, one needs
to resort to tricks to get call by expression/reference.  In most realistic
cases, the difference between these is one of efficiency.  If an operation 
can be done on the expression once and used many times, one perhaps wishes
to macro expand it or advise the compiler to do the processing once.
Since efficiency is a legitimate concern of programmers,
macros/quotes/compiling are in the game.

4. There is another mechanism besides macros one might use - partial
compilation or compile time calculation.  If an expression e contains
a subexpression s that one wishes to be evaluated, and its value used
in its place, quite a bit of optimization can be handled this way.
Especially for people trying to do knowledge-based programming (not only
in rules but inother forms as well) a good deal of knowledge-dependency
might be evaluated in once and for all - only if a compiler allows us
to use evaluate-once expressions.
-------