Christopher C. Stacy <cstacy@dtpq.com> wrote:
+---------------
| Mark Jeffcoat ("Mark") writes:
| Mark> (defun ctoi (d)
| Mark> (- (char-code d) #.(char-code #\0)))
| Mark> I do not understand what the "#." is doing there.
|
| He wants to subtract a constant, and just writing the call to
| CHAR-CODE would mean computing the constant every time the function
| was called. Assuming that the compiler was not smart enough to notice
| that this was a constant expression, he used the #. macro to ask that
| the call be done at compile-time.
+---------------
Oops! I'm sure this was just a slip o' the keyboard typo, Christopher,
but for Mark's sake we should be clear that that the evaluation is
occurring not at compile time but at *read* time, and thus is also
available in the REPL (as well as in interpreted code, if such a thing
exists in one's implementation):
> '(- (char-code d) #.(char-code #\0))
(- (CHAR-CODE D) 48)
>
Mark, see CLHS "2.4.8.6 Sharpsign Dot" <URL:http://www.lispworks.com/
reference/HyperSpec/Body/02_dhf.htm>.
-Rob
-----
Rob Warnock, PP-ASEL-IA <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607