4 ms·
My favorite common lisp thing is the special operator `the`. http://clhs.lisp.se/Body/s_the.htm http://clhs.lisp.se/Body/s_the.htm `the value-type form) => res
by shadowgovt 5y ago
My favorite common lisp thing is the special operator `the`. http://clhs.lisp.se/Body/s_the.htm http://clhs.lisp.se/Body/s_the.htm
`the value-type form) => result*`
Looking at its use, you might think it lets you declare types of things for type-checking purposes. i.e.
(the integer (operate-on 1))
... would make the program assert-fail if (operate-on 1) were somehow not an integer.
The real story is it can do that, but the spec actually says behavior is undefined if the value is not the specified type. So check-failing is one of the many things it's allowed to do.
In practice, depending on your compiler settings, `the` can act like asserts or it can act like places the compiler's allowed to paint racing-stripes on your code to make it go faster by skipping dynamic type checks and letting data structures mangle up if the types are wrong. ;)*
- User23 5y agoOr both! The CMUCL and SBCL compiler manuals are well worth a read.