[squeak-dev] change class to object

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] change class to object

Gaboto
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


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] change class to object

Miguel Cobá
anObject become: aClass

but read the class comments for notes


On Tue, May 12, 2009 at 6:25 PM, Gabriel Brunstein <[hidden email]> 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
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] change class to object

hernanmd
In reply to this post by Gaboto
#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 <[hidden email]>:
> 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
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] change class to object

Gaboto
Thanks!

On Tue, May 12, 2009 at 8:31 PM, Hernán Morales Durand <[hidden email]> 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 <[hidden email]>:
> 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
>
>
>




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] change class to object

Göran Krampe
In reply to this post by Miguel Cobá
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


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] change class to object

Gaboto
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 <[hidden email]>
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





Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] change class to object

Miguel Cobá
In reply to this post by Göran Krampe
Indeed a misunderstanding of the question.
To fast to respond, to lazy to reread the question :)

Miguel Cobá

2009/5/14 Göran Krampe <[hidden email]>:

> 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
>
>
>

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: change class to object

Sophie424
In reply to this post by hernanmd
On 2009-05-12 18:31:34 -0500, Hernán Morales Durand
<[hidden email]> 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?




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: change class to object

hernanmd
Dolphin:
#becomeAn:

VisualAge:
#fixClassTo: , #changeToClass:

VisualWorks:
#changeClassTo:, #changeClassToThatOf:

But every Smalltalk has its own particularities and specific conditions.

2009/5/16 Sophie <[hidden email]>:

> On 2009-05-12 18:31:34 -0500, Hernán Morales Durand
> <[hidden email]> 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?
>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: change class to object

Eliot Miranda-2


On Sat, May 16, 2009 at 9:29 AM, Hernán Morales Durand <[hidden email]> 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 <[hidden email]>:
> On 2009-05-12 18:31:34 -0500, Hernán Morales Durand
> <[hidden email]> 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?
>
>
>
>
>




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: change class to object

Nicolas Cellier
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 <[hidden email]>:

>
>
> On Sat, May 16, 2009 at 9:29 AM, Hernán Morales Durand
> <[hidden email]> 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 <[hidden email]>:
>> > On 2009-05-12 18:31:34 -0500, Hernán Morales Durand
>> > <[hidden email]> 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?
>> >
>> >
>> >
>> >
>> >
>>
>
>
>
>
>