[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
TYPE-OF
OK, I think it's clear that you don't really want TYPE-OF to return "the
most specific type". Rather, you want it to be the case that TYPE-OF is
well-defined for all objects in Common Lisp, and that the definition,
which will be written out clearly somewhere, will tend to specify that
more-specific rather than less-specific types be returned. If some
implementation has its own even-more-specific type, TYPE-OF will not
return it.
Even so, I'm not sure I understand why you need TYPE-OF. As far as I
can tell, almost the only useful thing to do with a type is to see
whether some object is of that type, and that's what TYPEP is for.
In your D-Eval example, evaluating (foo 1) returned 2 and printed out ";
FIXNUM". If you had said (foo 0), it would have returned 1, but would
it have printed out "; BIT"? Apparently not, because that's not in your
list of number types. On the other hand, why doesn't 2 print out ";
INTEGER"? That is, why does your list exclude BIT but include FIXNUM
and BIGNUM? Whether an integer is a FIXNUM or not depends on the
implementation, and usually it's better to hide it than draw attention
to it. Same question for the different floating point formats. In
order to make TYPE-OF fully-defined, some kinds of decisions have to be
made, and some of them seem rather arbitrary (in the sense that it's not
really clear which decision is best).
- Follow-Ups:
- TYPE-OF
- From: Guy Steele <gls@think.com>
- References:
- TYPE-OF
- From: Masayuki Ida <a37078%ccut.u-tokyo.junet%utokyo-relay.csnet@RELAY.CS.NET>