"But I need types," he told me.Humans have a tendency toward binary thinking (pardon the pun). If it's not A, it's B. Perhaps because Lisps have REPLs, they are often thought of from the outside as being dynamic, interpreted languages. Our years of Python have taught us that such languages don't really have strong typing - it's all a wild guess until the interpreter calls foo on a and b and we find out who everyone really is.Yet Common Lisp is fully typed, and AOT compiled. You can assign strict types to variables and entire functions, and the compilers will use this both for optimization and general correctness checking, and you can freely inspect the assembly code of any compiled function. All of this while maintaining the fluidity of development flows usually reserved for dynamic languages.But we're not here today for the revelation that Common Lisp has types.This article elaborates Common Lisp's conception of "types" and their triple-natured reality, answering the questions:What is a type?What is a class?What is the machine really doing?Types are of the SkyI settled on Common Lisp two years ago because I found it to be the most debuggable language I had tried in my career. The time between discovery of the What of a problem to the Why is the shortest for me in this language, and this is due to how inspectable everything is.In Common Lisp, each type is a set, and each piece of Lisp data belongs to at least one. We can ask any such data value for its type:(INTEGER 0 4611686018427387903)An unsigned integer, by the looks of it, of 62-bit range. How about a string literal?(SIMPLE-ARRAY CHARACTER (1))A one-dimensional, length-one array of character values.We can interrogate these values a bit further:(list (typep 37 'integer) (typep 37 'real) (typep 37 'number) (typep 37 t))(T T T T)Where T means "True".(list (typep "漣" 'simple-array) (typep "漣" 'string) (typep "漣" 'vector) (typep "漣" 'array) (typep "漣" t))(T T T T T)As we can see, these types form larger and larger s...
First seen: 2025-09-02 13:51
Last seen: 2025-09-02 19:52