In Maclisp, the function typep
takes one argument and returns its type in the form of a symbol. This is a fundamental operation, and it's egregiously misnamed, as it's not a predicate. (The -p
convention is much older than typep
, so the name was misleading even in Maclisp.) Lisp Machine Lisp preserved it for compatibility, but Common Lisp fixes the confusion by calling it type-of
and using typep
only for the two-argument type membership predicate.
I've never used Maclisp, nor any dialect with one-argument typep
, so this misnaming should interest me only as historical trivia. But I find it oddly compelling. When I read typep
, I think of the unary version first, and only remember the type membership test when context reminds me. When I refer to the “what type is this?” operation without having a specific language in mind, I tend to carelessly call it typep
.
Why? I suspect it's because the most obvious name, type
, is too bare — it sounds like it might collide with something else, although it doesn't in either Maclisp or Common Lisp — so I look for an affix to distinguish it. The -of
in type-of
works, but it's meaningless and irregular, and sounds wrong — more like function application than part of a name. -p
is semantically inappropriate, but it's so common and familiar that it sounds right anyway. So I latch onto it and don't think about the meaning.
I can't be the only one with this problem. I've heard other people call it “one-argument typep”, and someone must have made the same mistake decades ago to give typep
its misleading name in the first place. (Was it derived from a predicate? Did its designers have a different interpretation in mind, like “return the type predicate that's true of this value”?) If you are also drawn to this misnomer, or if you know more of its history, I'd like to hear about it.
Followup: How typep got its name