Infrequently Asked Questions
Infrequently Asked Questions about CL

This page is humor, and should not be mistaken for a real source of information. See Annotations for Infrequently Asked Questions if you want to spoil the jokes for yourself, some of which are actually funny.

Can we write something like Infrequently Asked Questions in comp.lang.c [warning: this document requires very good C knowledge to catch all jokes in it] for CL? Maybe it is not possible to write it for CL due to nature of language but it might be interesting to try and identify parts that can to make things better and to have fun of it.

Document conventions

Source code is written in monospaced font. Prompt and results are written in italics.

Section 1, symbols and numbers

Q: What is difference between nil and () ?
A: The first is composed of three characters, the second isn't. Q: Seriously, can nil and () be unequal?
A: Ok, seriously. () will always make nil (with exception of abusing the read macros). Nil can be equal to 30477 unlike (). Q: How can be that NIL and nil is same symbol?
A: nil is special constant that always evaluate to same symbol. Q: How can I enter numbers in hexadecimal?
A: You can enter numbers in hexadecimal after this trick: (setq *read-base* 16) Example:
<i>[1]</i> (setq *read-base* 16)
<i>=> 16</i>
<i>[2]</i> ffff
<i>=> 65535</i>
Q: What's wrong with changing read base back to decimal in this way: (|setq| |*read-base*| 10)
A: You need to write it in upper-case. Q: What's a 'special variable'?
A: Some variables have values that must be accessed very quickly. They are stored in memory that is connected to the CPU by a high speed datapath called 'the short bus'. Special variables ride the short bus.

Section 2, Evaluation and functions

Q: Why does (READ-FROM-STRING "foobar" :START 3) return FOOBAR instead of BAR?
A: Real reason is that there are actually two starts. The first is ignored. Write it this way: (READ-FROM-STRING "foobar" :START 3 :START 3) Q: Why I can't APPLY #'AND and #'OR.
A: Contrary to what your mathematicians say, AND and OR are not functions. Q: What does mean that AND, OR and some others are short-circuiting?
A: This is jargon taken from electroincs. i.e. When you have two AND gates that have outputs connected, they may short circuit depending on inputs. Q: Why (sort my-variable) does not update the variable?
A: Default calling convention in Common Lisp is call by value, it cannot modify arguments passed in. Try to find compiler switch to make it call by reference. Q: What is faster, length or list-length?
A: Surly list-length. Just compare speed of following expressions:
(list-length '#1=(1 . #1#))
and
(length '#1=(1 . #1#))

Section 3, Historical facts

Q: Why are some basic functions named in so weird way (I mean CAR, CDR, MAPCAR and so on)?
A: There is a reason for it. Designers of lisp were actually in very hurry when they designed. They needed to release version 1.5 to the market very soon. Due to lack of imagination they have problems thinking out the names so they just looked at things around and use their names or abbreviations as identifiers (hint: CDR is relatively unknown car manufacture, that also explains old joke "My other CAR is CDR"). Rumors that CAR have something to do with registers are completely nonsense. Q: What is CDR coding?
A: CDR coding is programming style where programs looks like this (incomplete) example:
(CDR (CDR (CDR (CDR (CDR (CDR (CDR (CDR (CDR (CDR (CDR (CDR
Q: Is CDR coding useful?
A: Programs written in CDR coding style may be faster, especially on hardware with CDR coding support.

Section 4, ANSI standardization

Q: People keep saying the behavior is undefined, but I just tried it on an ANSI-conforming compiler, and got the results I expected.
A: They were probably wrong. Flame them mercilessly. Be sure before you do that your compiler is really ANSI conforming, though. If it turns out you were wrong, they get a legal claim on your first-born.
Note the similarity of the question and the answer to one found in C language Infrequently Asked Questions. This one is really common to all standardized languages.

Section 5, Performance

Q: I have heard that Java is slower than Common Lisp
A: Languages don't have speed. However their implementation have. We have found most Common Lisp implementations to be slower than Java. See following Java code:
class MyClass {
    static void myloop() {
        myloop();
    }
    public static void main(String[] args) {
        myloop();
    }
}
Compare with following Common Lisp code (myloop function have to be compiled):
(defun myloop () (myloop))
(myloop)
Sun Java 1.4.1_01 finished execution after about a second. Both CMUCL 18d and CLISP 2.30 did not finish the program in 30minutes. It is evident that Java is much faster. Only advantage of Common Lisp is that the code is shorter.
Add more if you know. -jtra