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

→‎What's exactly monkeypatching?: task text changed; still no solution for smalltalk, maybe it must be moved to omit from... or smalltalk guru needed
(→‎That articles task: Need data manipulation too?)
(→‎What's exactly monkeypatching?: task text changed; still no solution for smalltalk, maybe it must be moved to omit from... or smalltalk guru needed)
 
(One intermediate revision by one other user not shown)
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)
::: Almost, but somewhere past in time it changed. Before the changing, it cited Smalltalk among langs able to do this kind of monkypatching à la Pythonistas, and this made the task unclear for a poor smalltalker (what an irony!) like me. Luckly the citation to Smalltalk disappeared but unluckly I am not still able to fix it (I still think Smalltalk can't). --[[User:ShinTakezou|ShinTakezou]] 11:14, 2 June 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.