dynamic-mixins icon indicating copy to clipboard operation
dynamic-mixins copied to clipboard

Add method for CHANGE-CLASS

Open pfdietz opened this issue 5 years ago • 3 comments

It should be possible to use a mix list as an argument to change-class, not just to make-instance.

pfdietz avatar Mar 17 '20 21:03 pfdietz

Sure ... not really doing CL at the moment, but I'll merge a straightforward PR.

I'm not sure if this was ever a great idea and/or should actually be used though ;)

rpav avatar Mar 17 '20 21:03 rpav

I have a use case for it, although the problem could be solved other ways,

The situation is where one wants to temporarily attach extra data to objects in some data structure. For example, in a graph data structure, one might want to add some slots for marks or pre/post order numbers for doing depth first search. The usual way to do this is to build an EQ hash table indexed by the objects and store the data there. Instead, one could temporarily extend the objects with the extra fields, then revert them back to the original form when done.

With dynamic mixins, the logic for all this could be in the graph algorithm library; it needn't be in the data structure itself.

pfdietz avatar Mar 18 '20 13:03 pfdietz

"Destructive walking" doesn't seem like a great idea to me, what about concurrency and reentrancy? I wonder if change-class might be a bit of a heavyweight operation if you're going to invoke it repeatedly on the critical path (such as at every node of a big graph). I would also worry about getting in an inconsistent state if a problem occurs during walking. I think the eq hash-table is a pretty great solution, since it's highly non-intrusive and eq hashing ought to be very fast...

Hexstream avatar Apr 02 '20 18:04 Hexstream