3 ms·
> type declarations are unsafe even at the highest safety settings because of "what implementations do." Type declarations are not unsafe at highest safety set
by lispm 9y ago
> type declarations are unsafe even at the highest safety settings because of "what implementations do."
Type declarations are not unsafe at highest safety settings in most Common Lisp implementations.
Personally I write code for real actual implementations and their documented behavior - and not just for a spec. They implement the pragmatic part of a programming language, extend it with various features. The CL spec for example says nothing about GC - which would make memory allocation 'unsafe' when we follow your arguments - fortunately implementations provide GCs. Similar, implementations provide a mode when safety = 3 where full runtime type checks are enabled.
I for example sometimes exploit that parts of the implementation is using CLOS for built-in functionality where the spec does not require the use of CLOS (streams is an example) - knowing that this code will not run in some - often also uninteresting for me - implementations.
> SBCL's new behavior would have burned me, causing aborts in perfectly working code just because I got my "documentation" wrong.
That's true, SBCL tells you that your documentation is wrong. Which is a good thing. Somebody would read your code and would be confused by your wrong type declarations.
Actually: wrong type declarations for optimization purposes is the real danger. SBCL helps to find the problems.
> encouraging the use of declarations everywhere is wrong. To do so, in the words of PuercoPop, is "missing the point of the Lisp's type system." SBCL is wrong to do it.
That's not what SBCL does. SBCL allows you to add declarations. But also SBCL does type inference, so types get propagated without the need to type everything. Most better Lisp compilers do forms of type inference. I also gave you an example where SBCL takes advantage of method argument lists - thus you don't need to add type declarations, since the method already tells which class the argument is of.
Advice: follow the spec, but understand the broader Common Lisp tradition codified in its implementation.