[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mutable handler for rationals
From: Todd Allen <Allen>
To: T-Bugs
It'd be nice if rational numbers had mutable handlers. I have some
code which takes advantage of the fact that handle-fixnum,
handle-flonum, and handle-bignum are available if you really want
them. It's a real pain to have to provide default methods and test
(RATIO? obj) all the time.
Things are going in the opposite direction from this. Your code is
likely to break in release 2.8 or 2.9 because the primitive types
will no longer have mutable handlers. Mutable handlers for primitive
types conflict with the goal of eliminating global state from the
system internals; that's why they were never released in the first
place.
Ought not set-method be released and documented? At least, in the
context of structures?
SET-METHOD is also going away. DEFINE-METHODS will work for a while,
but only for as long as it takes for a better alternative to be
developed and for people to convert their code. DEFINE-METHODS ought
to be documented, but it didn't quite make it into the 4th edition
(partly for this reason). It works like this:
(DEFINE-METHODS (STYPE-HANDLER FOO-STYPE)
((OP1 OBJ1 . ARGS1) . BODY1)
...
((OPN OBJN . ARGSN) . BODYN))
says that when OPJ is invoked on structures of type FOO-STYPE, the
variable OBJJ is bound to the structure, ARGSJ are bound to the
other arguments to the operation, and BODYJ is evaluated.
The current DEFINE-METHODS is inadequate given the existence of JOIN
because it assumes that SELF and the structure itself are the same.
In the future the syntax will have to allow for another bound variable
so that the two may be named independently.