|[Top]||[Contents]||[Index]||[Page Top / Bottom]|
"But no one can read the program without understanding all your new utilities." To see why such statements are usually mistaken, see Section 4.8.
You could write this more elegantly with the new Common Lisp series macros, but that only proves the same point, because these macros are an extension to Lisp themselves.
Under dynamic scope the same idiom will work for a different reason--so long as neither of mapcar's parameter is called x.
The declaration (optimize speed) ought to be an abbreviation for (optimize (speed 3)). However, one Common Lisp implementation does tail-recursion optimization with the former, but not the latter.
An explanation of why it is bad to call eval explicitly appears on page 278.
It's ok to have this code in a file and then compile the file. The restriction is imposed on interpreted code for implementation reasons, not because there's anything wrong with defining functions in distinct lexical environments.
For a characteristic example, see page 242.
A definition of referential transparency appears on page 198.
For an introduction to packages, see the Appendix beginning on page 381.
Except perhaps remove-if-not, which is used more often than remove-if.
Under dynamic scope, we could write something like make-adder, but it would hardly ever work. The binding of n would be determined by the environment in which the returned function was eventually called, and we might not have any control over that.
In one widely used Common Lisp, functionp erroneously returns true for t and nil. In that implementation it won't work to give either as the second argument to lrec.
In some implementations, you may have to set *print-circle* to t before these functions can be displayed.
This version assumes that the network is a tree, which it must be in this application.
Backquote can also be used to create vectors, but this is rarely done in macro definitions.
This macro is defined a little oddly to avoid using gensyms. A better definition is given on page 150.
This version is written in this strange way to avoid using gensyms, which are not introduced till later.
5 For an example of macro where this distinction matters, see the note on page 393.
Except functions compiled inline, which impose the same restrictions on redefinition as macros.
Made from, in the sense that lists are the input to the compiler. Functions are no longer made of lists, as they used to be in some earlier dialects.
For clarity, this version ignores all the bookkeeping that defun must perform.
The definition of this macro anticipates the next chapter by using gensyms. Their purpose will be explained shortly.
This macro is used only as an example. Really it should neither be implemented as a macro, nor use the inefficient algorithm that it does. For a proper definition, see page 50.
`',(foo) is equivalent to `(quote ,(foo)).
It's not impossible to write an iteration function which doesn't need its argument wrapped up in a function. We could write a function that called eval on expressions passed to it as arguments. For an explanation of why it's usually bad to call eval, see page 278.
This definition is not correct, as the following section will explain.
A function name in the general sense: either 1+ or (lambda (x) (+ x 1)).
The third value is currently always a list of one element. It is returned as a list to provide the (so far unconsummated) potential to store multiple values in generalized variables.
Built-in functions should not be memoized in this way, though. Common Lisp forbids the redefinition of built-in functions.
Although one tends to think of and and or together, there would be no point in writing an anaphoric version of or. An argument in an or expression is evaluated only if the previous argument evaluated to nil, so there would be nothing useful for an anaphor to refer to in an aor.
Though the abbreviation can't be passed to apply or funcall.
Functions created by =defun are deliberately given interned names, to make it possible to trace them. If tracing were never necessary, it would be safer to gensym the names.
Since the order of argument evaluation is unspecified in Scheme (as opposed to Common Lisp, which specifies left-to-right), this call might also return (THE SUM OF 5 2).
If desired, the exported interface to this code could consist of just a single operator, because (fail) is equivalent to (choose).
Many of the concepts used in this chapter, including this sense of bindings, are explained in Section 18.4.
A more sophisticated version of this code could use reduce to avoid consing here.
Since the combination function for props calls union, the list elements will not necessarily be in this order.
Or more precisely, on the type-like classes that CLOS defines in parallel with the Common Lisp type hierarchy.
In one (otherwise excellent) Common Lisp implementation, concatenate will not accept cons as its first argument, so this call will not work.
In older implementations of Common Lisp, omit the :use argument.
Some implementations of Common Lisp print the package name before the toplevel prompt whenever we are not in the user package. This is not required, but it is a nice touch.