Abstract
To be honest, I couldn’t find a better title for this chapter. It’s kind of a hodgepodge of various subjects, although many of them would probably indeed fit into the chapter called Evaluation and Compilation in the Common Lisp standard.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
See Recipe 3-4 for strings and characters. For numbers and you only need to be careful if you’re comparing rationals with floating-point numbers (see Recipe 4-10), which is questionable style anyway.
- 2.
Yeah, other Lispers might give you different advice. But, hey, whose book is this? Also, rules are there to be broken once you’ve understood them…
- 3.
Being always very careful with the wording, they are actually a bit pickier. Two objects can be the same object with respect to some specific predicate and if there’s no predicate mentioned, then EQL is implied. Whereas identical means “the same under the predicate EQ.”
- 4.
If you want a comparison, it is as if a C programmer would rely on int always being 16 bits wide.
- 5.
It is roughly equivalent to what == does in Java.
- 6.
- 7.
See Recipe 18-4.
- 8.
That’s the term used in the standard. As we will soon see, this doesn’t necessarily imply that this is a keyword in the sense of being a symbol from the KEYWORD package.
- 9.
In Java, a similar concept would be that of a static member variable.
- 10.
If not, you might want to read Chapter 6 of Practical Common Lisp.
- 11.
You could, for example, bind the variable to NIL when the function is defined and in MY-COUNT check if it’s still NIL.
- 12.
See 3.2.3.1 of the standard.
- 13.
GET-INTERNAL-REAL-TIME is explained in Recipe 22-8.
- 14.
Although implementations are technically not required to adhere to this.
- 15.
Of course, the behavior is meticulously described in the standard.
- 16.
This is explained in Chapter 16 of Practical Common Lisp, which is also available online at http://www.gigamonkeys.com/book/object-reorientation-generic-functions.html .
- 17.
And it has, by the way, also been a part of GNU Emacs since 1994.
- 18.
Or rather only in the form of the auxiliary methods mentioned above.
- 19.
See Recipe 10-8.
- 20.
See Recipe 4-4 for an explanation of the "~@R" part.
- 21.
In other words, this also works with DEFGENERIC and DEFMETHOD.
- 22.
See more in Chapter 6 of Practical Common Lisp which is at http://www.gigamonkeys.com/book/variables.html .
- 23.
If you want to follow along, ask your IDE to undefine (see Recipe 16-9) the function (SETF NUMBER-WORD) or start a new image and define only the hash table and the NUMBER-WORD function.
- 24.
We wrapped the output of GETHASH with VALUES to get rid of the second return value, but that is only for cosmetic reasons.
- 25.
For LDB and BYTE see Chapter 24 of Practical Common Lisp.
- 26.
This also shows, by the way, that somewhere during the evaluation of this form both our update and our access form were used. Have a look at a possible setf expansion of LDB in the dictionary entry for DEFINE-SETF-EXPANDER if you’re wondering why this is so.
- 27.
Note the use of the environment parameter (see Recipe 10-9).
- 28.
In case you’re still somewhat unsure about how this macro should be used, its HyperSpec dictionary entry also contains some examples. And one more is following on page 293.
- 29.
See http://www.lispworks.com/documentation/HyperSpec/Issues/iss174_w.htm . Before function names like (SETF FOO) were allowed, the only way to write setf accessors was with macros and for that DEFSETF was the more convenient variant. It probably was left in for backward compatibility.
- 30.
Note that according to the standard it is implementation-dependent whether the expansion of a symbol macro is stored in the environment; which means that this example might not work the same with other Lisps.
- 31.
We’ll use the terms environment and environment object interchangeably from now on, although technically there is a difference. An environment object is something like what was bound to ENV in our example, while there are usually several environments that are active at any given point in the execution of a program. The environment object can be used to query these environments.
- 32.
See, for example, Recipe 17-3.
- 33.
Available online at http://www.cs.cmu.edu/Groups/AI/html/cltl/cltl2.html .
- 34.
And make sure to compile SLOW-AND-EXACTafter the compiler macro was defined or else it won’t have any effect.
- 35.
The NOTINLINE declaration is in there to prevent the compiler macro from being called again and again on the same form.
- 36.
Look up *READ-SUPPRESS* in the standard for details.
Author information
Authors and Affiliations
Electronic Supplementary Material
Below is the link to the electronic supplementary material.
Rights and permissions
Copyright information
© 2016 Edmund Weitz
About this chapter
Cite this chapter
Weitz, E. (2016). Chapter 10: Evaluation, Compilation, Control Flow. In: Common Lisp Recipes. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-1176-2_10
Download citation
DOI: https://doi.org/10.1007/978-1-4842-1176-2_10
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-1177-9
Online ISBN: 978-1-4842-1176-2
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)