freenode/#sbcl - IRC Chatlog
Search
9:31:17
flip214
I'm parsing some text, and depending on what is found I call MAKE-INSTANCE with some class.
9:31:44
flip214
Later on I might find that there's some additional information for an instance and so call CHANGE-CLASS.
9:32:40
flip214
But choosing the "big" class first time around isn't nice either, it needs more memory...
10:25:18
flip214
Is there a definition whether (CHANGE-CLASS instance 'new-class :slot "value") has to change the slot's value if instance is already of class 'new-class?
10:44:42
flip214
Although "After completing all other actions, change-class invokes update-instance-for-different-class" might need a bit more thought... should that be called at all if it's not a different class?
11:23:21
flip214
stassats: according to CLHS not. http://clhs.lisp.se/Body/f_chg_cl.htm "If in the old class there is any slot of the same name as a local slot in the new-class, the value of that slot is retained"
11:23:40
flip214
so yes, processed as in "values calculated", but not as in "values assigned to class instance"
11:28:47
flip214
wouldn't it be nice to get a big speedup, even if it's just some small corner case?
11:30:20
flip214
yeah, I changed my (typecase instance) to (case (class-name (class-of instance)) ...) already... but others might not even notice what's taking so long
11:50:47
stassats
scymtym: a ctor-like thing could precompute the intersection of slots for processing, if not fully speed things up
13:02:33
scymtym
stassats: yes. not sure it would be worth the effort, though. that said, i have seen a few cases in which a faster CHANGE-CLASS would have been handy
13:03:59
stassats
as with optimized make-instance, it can avoid calling update-instance-for-different-class altogether