[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

underspecified type-of



CommonLoops gets around the underspecified nature of type-of by defining
"class-of". Class-of is defined to work for all Lisp data types, and
always returns a "class" object. While implementations may have
implementation-dependent classes (e.g., (class-of 3) may be different
than (class-of 123123123123123123)), the classes themselves observe a
well-behaved protocol, e.g., (subclassp (class-of 3) (class-named
'number)).

As you point out, "type-of" is portably useful only for structures,
since it would be valid for implementations to always return "t"
otherwise. 

- - - - - -
On a side note: we had a user trying to port code from another Common
Lisp in which (he claims) it is legal to do 

(defstruct env part1 part2)
(setq x (make-env))
(eq (aref x 0) 'env)

While implementations can implement structures using "arrays", isn't it
"an error" to call AREF on an instance of one? (E.g., should a "maximal
error checking" implementation always signal an error in this case?)

I've looked carefully in the defstruct section and also the section in
arrays, and I don't see anything that explicitly rules this out,
although it is clearly non-portable.