Maybe this question is too general, nevertheless i\'ll try: Is there any comprehensive guide on types in common lisp?
I\'m kind of confused about this subject:
Why are non-primitive types declared in make-array's :element-type are promoted to t? Is there any possibility for compile-time or runtime checks of the real declared type?
The :element-type
parameter is there that an implementation can choose an optimized memory layout for an array - mostly for saving memory space. This is typically useful with primitive types. For other types most Common Lisp runtimes will have no optimized storage implementation and thus the declaration will have no useful effect.
Why are CLOS slot defined types don't work as constraints, allowing to put value of any type into the slot? Again, what about the checks?
An implementation may do that.
Clozure CL:
? (defclass foo () ((bar :type integer :initform 0 :initarg :bar)))
#
? (make-instance 'foo :bar "baz")
> Error: The value "baz", derived from the initarg :BAR,
can not be used to set the value of the slot BAR in
#, because it is not of type INTEGER.
The same for the functions' types declarations with declare.. Are they just the optimization hints to the compiler?
The type declarations with declare can be ignored - for example in Symbolics Genera most declarations will be ignored. Implementations are not required to process them. Most implementations will at least interpret them as assurance that some object will be of that type and create optimized code for that - possibly without runtime checks and/or specialized code for that type. But it's usually necessary to set corresponding optimization levels (speed, safety, debug, ...)
Additionally compilers derived from CMUCL's compiler (SBCL, ...) may use them for some compile time checks.
But none of the effects is specified in the ANSI CL standard. The standard provides the declarations and leaves the interpretation to the implementations.