Over at the newly redesigned Common Lisp Wiki, CLiki, they have an excellent page on Common Lisp naming conventions. Most people that have done a non-trivial amount of Lisp programming will be at least dimly aware of many of these conventions but there’s also a number of rarer conventions that may be new to many.
Most Lispers know the “predicate convention:” predicates end with “p” unless the predicate contains a hyphen, in which case it ends with “-p”. Thus it’s zerop
and simple-vector-p
. But what about string-lessp
? That seems to violate the convention and I’ve always wondered why. It turns out that the actual convention has a third part that says if a new predicate is formed by adding a qualifying prefix to an existing predicate, then the new predicate is formed by adding a hyphen between the prefix and old predicate and the “p” or “-p” at the end is unchanged. Thus when lessp
is qualified with the prefix string
we get string-lessp
instead of string-less-p
. Follow the link for the rationale for this rule. Of course, there’s also the grandfathered-in predicates such as null
and equal
that don’t honor the p convention at all.
There are other interesting notes about the conventions so even experienced Lispers are likely to find the page interesting. If you program in Common Lisp you should check it out.