does anyone knows how to change the class of an object? I know there is a message to send to do that, but I cant find it.Thanks! Gabo
anObject become: aClass
but read the class comments for notes
On Tue, May 12, 2009 at 6:25 PM, Gabriel Brunstein gaboto@gmail.com wrote:
does anyone knows how to change the class of an object? I know there is a message to send to do that, but I cant find it. Thanks! Gabo
The message #become: changes an object with another, indeed, it changes all the references to this object to point to the other one. It can be useful, for example, when your want an object to be wrapped by another one, so you can replace the original object with the wrapper in the whole image (It takes a long time so it is an inefficient way to do that)On the other hand, #primitiveChangeClassTo: changes the class of an object with another one. It is useful when you want to implement an instance wrapper for example (read more on the paper called "wrappers to the rescue").
2009/5/14 Göran Krampe goran@krampe.se
Miguel Cobá wrote:
anObject become: aClass
but read the class comments for notes
Ehrmm... eh, nope. That would not be a good thing to do. ;) Was this just a guess or a true misunderstanding of the question? Just curious.
regards, Göran
Indeed a misunderstanding of the question. To fast to respond, to lazy to reread the question :)
Miguel Cobá
2009/5/14 Göran Krampe goran@krampe.se:
Miguel Cobá wrote:
anObject become: aClass
but read the class comments for notes
Ehrmm... eh, nope. That would not be a good thing to do. ;) Was this just a guess or a true misunderstanding of the question? Just curious.
regards, Göran
#primitiveChangeClassTo:
You can see a working example in the Instances Browser : http://www.squeaksource.com/LightweightClasses.html
Cheers
Hernán
2009/5/13 Gabriel Brunstein gaboto@gmail.com:
does anyone knows how to change the class of an object? I know there is a message to send to do that, but I cant find it. Thanks! Gabo
Thanks!
On Tue, May 12, 2009 at 8:31 PM, Hernán Morales Durand < hernan.morales@gmail.com> wrote:
#primitiveChangeClassTo:
You can see a working example in the Instances Browser : http://www.squeaksource.com/LightweightClasses.html
Cheers
Hernán
2009/5/13 Gabriel Brunstein gaboto@gmail.com:
does anyone knows how to change the class of an object? I know there is a message to send to do that, but I cant find it. Thanks! Gabo
On 2009-05-12 18:31:34 -0500, Hernán Morales Durand hernan.morales@gmail.com said:
#primitiveChangeClassTo:
You can see a working example in the Instances Browser : http://www.squeaksource.com/LightweightClasses.html
Is this portable across Smalltalks, or Squeak-specific?
Dolphin: #becomeAn:
VisualAge: #fixClassTo: , #changeToClass:
VisualWorks: #changeClassTo:, #changeClassToThatOf:
But every Smalltalk has its own particularities and specific conditions.
2009/5/16 Sophie itsme213@hotmail.com:
On 2009-05-12 18:31:34 -0500, Hernán Morales Durand hernan.morales@gmail.com said:
#primitiveChangeClassTo:
You can see a working example in the Instances Browser : http://www.squeaksource.com/LightweightClasses.html
Is this portable across Smalltalks, or Squeak-specific?
On Sat, May 16, 2009 at 9:29 AM, Hernán Morales Durand < hernan.morales@gmail.com> wrote:
Dolphin: #becomeAn:
VisualAge: #fixClassTo: , #changeToClass:
VisualWorks: #changeClassTo:, #changeClassToThatOf:
Note that VW's #changeClassTo: is built upon Behavior>>adoptInstance: which is a much better primitive for the VM to implement since it can assume the receiver is a valid behaviour. The changeClassToThatOf: primitive is also designedto avoid checking for a valid behaviour. If I were to attempt to standardize I would do so based on adoptInstance:.
But every Smalltalk has its own particularities and specific conditions.
2009/5/16 Sophie itsme213@hotmail.com:
On 2009-05-12 18:31:34 -0500, Hernán Morales Durand hernan.morales@gmail.com said:
#primitiveChangeClassTo:
You can see a working example in the Instances Browser : http://www.squeaksource.com/LightweightClasses.html
Is this portable across Smalltalks, or Squeak-specific?
Thanks to Eliot for reminding this way of Smalltalking. Why bother with tests when message dispatching does that so well.
Nicolas
2009/5/16 Eliot Miranda eliot.miranda@gmail.com:
On Sat, May 16, 2009 at 9:29 AM, Hernán Morales Durand hernan.morales@gmail.com wrote:
Dolphin: #becomeAn:
VisualAge: #fixClassTo: , #changeToClass:
VisualWorks: #changeClassTo:, #changeClassToThatOf:
Note that VW's #changeClassTo: is built upon Behavior>>adoptInstance: which is a much better primitive for the VM to implement since it can assume the receiver is a valid behaviour. The changeClassToThatOf: primitive is also designedto avoid checking for a valid behaviour. If I were to attempt to standardize I would do so based on adoptInstance:.
But every Smalltalk has its own particularities and specific conditions.
2009/5/16 Sophie itsme213@hotmail.com:
On 2009-05-12 18:31:34 -0500, Hernán Morales Durand hernan.morales@gmail.com said:
#primitiveChangeClassTo:
You can see a working example in the Instances Browser : http://www.squeaksource.com/LightweightClasses.html
Is this portable across Smalltalks, or Squeak-specific?
squeak-dev@lists.squeakfoundation.org