opening it up with Common Lisp
Book review: Darwinia
Summer reading: Spin
the Omnivoire's Delimma
the Golem's Eye
(updated 21 June 2005)
Common Lisp lets you change the class of things on the fly and in fact has a whole protocol for dealing with appearing and disappearing slots, updating existing instances and so forth. It's really quite amazing and very handy for prototyping and ad hoc experimentation. My only complaint is that changing the class of an object takes way too much typing! You need to
This seems silly to me. Why not make class changing as simple as setting any other sort of value? Why not make it seem like Common Lisp by using setf? Why not make it more flexible? So, since I couldn't think of any not to, I wrote this:
This lets me do things like
and that's easier to type, looks like CL, and is even clearer (in my opinion). Any dissenting voices are welcome to comment!
Well, it looks like I've put my foot in it! Not only can you already say things like
but redefining a built in symbol of the Common Lisp package like class is -- of course -- a no-no. My implementation also ignores the fact that you might want to add initargs to the change-class form (though that's easy to fix). On the other hand, I still think that using setf to change classes is a good idea. My general philosophy of change in Lisp is that if you can use setf, then you should. In any case, thanks for the feedback.
Copyright -- Gary Warren King, 2004 - 2006