Talk:Add a variable to a class instance at runtime: Difference between revisions

(Try to help understanding of the task description)
Line 10:
 
: The task description is clear enough. Add the new things to an instance of the class without modifying the class (i.e., other instances of the class must be unaffected). What would be a more exciting way to do it would be to dynamically create a subclass of the class with the required modifications and then change the class of the instance ''after creation'' to the subclass. For one thing, that's a sequence of operations that shows that a simple type algebra isn't sufficient to understand the object system… –[[User:Dkf|Donal Fellows]] 01:32, 5 January 2010 (UTC)
 
:: The task description is certainly not clear enough if it means what you say it means, Donal. One reason for disagreement is now obvious to me: in Smalltalk, classes are objects like any other. So a "class instance" is just the run-time representation of a class, as opposed to "an instance of a class". But that's actually a minor point. The major point is that it refers to [http://en.wikipedia.org/wiki/Monkey_patch:Monkey Patch], which on Ruby and Python communities refers to changing a ''class'', not an object. That's so much true that one of the criticism leveled at monkey patching as practiced in the Ruby community is that sometimes different libraries perform incompatible changes to class used by both, and that is very difficult to track.
 
::So, if something else is meant, I strongly suggest modifying the question to leave no question about it.
Anonymous user