|
|
|
|
|
by dreamcompiler
3088 days ago
|
|
> Note that Common Lisp has type declarations, which can move type errors from run-time to compile-time. This is a dangerous assumption. The standard does not require that Common Lisp type declarations cause the compiler to detect type inconsistencies (although some implementations might be smart enough to do so in some cases). CL type declarations tell the compiler it can remove runtime checks. They are performance optimizations. If anything they decrease type safety. |
|
That's not true. To tell the compiler that it can remove runtime checks you declare the optimization quality SAFETY to 0.
The Common Lisp standard does not specify what type declarations do and what the interpreter or compiler does with it.
Some compilers will never check types. Some will use them when SAFETY is low as assertions and remove runtime checks. Some will use them as assertions both at compile and runtime.
> They are performance optimizations. If anything they decrease type safety.
That depends on the implementation and the compiler switches.
In SBCL by default it INCREASES type safety: