Finding all references to an object

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

Finding all references to an object

Sean P. DeNigris
Administrator
I have an object, which I want to replace with a new object everywhere it exists in the system. How do I do that?

Thanks.
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Finding all references to an object

patmaddox
becomeForward: ?


On Aug 2, 2011, at 11:04 PM, Sean P. DeNigris wrote:

> I have an object, which I want to replace with a new object everywhere it
> exists in the system. How do I do that?
>
> Thanks.
> Sean
>
> --
> View this message in context: http://forum.world.st/Finding-all-references-to-an-object-tp3714218p3714218.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: Finding all references to an object

Sean P. DeNigris
Administrator
Pat Maddox-3 wrote
becomeForward: ?
Looks good, but what's the difference between become: and becomeForward: ?
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Finding all references to an object

patmaddox
On Aug 2, 2011, at 11:14 PM, Sean P. DeNigris wrote:

>
> Pat Maddox-3 wrote:
>>
>> becomeForward: ?
>>
>
> Looks good, but what's the difference between become: and becomeForward: ?

become: swaps the two objects entirely, becomeForward: "replaces" references with the argument. Check out the comments. But a basic example would be...

| a b |
a := 'foo'.
b := 'foobar'.
a becomeForward: b.
"a = 'foobar'  b = 'foobar'"

| a b |
a := 'foo'.
b := 'foobar'.
a become: b.
"a = 'foobar'  b = 'foo'"

Reply | Threaded
Open this post in threaded view
|

Re: Finding all references to an object

Sean P. DeNigris
Administrator
Pat Maddox-3 wrote
become: swaps the two objects entirely, becomeForward: "replaces" references with the argument.
Got it, thanks. The system tests (duh) for these are really clear.
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Finding all references to an object

patmaddox
On Aug 2, 2011, at 11:40 PM, Sean P. DeNigris wrote:

>
> Pat Maddox-3 wrote:
>>
>> become: swaps the two objects entirely, becomeForward: "replaces"
>> references with the argument.
>>
>
> Got it, thanks. The system tests (duh) for these are really clear.

it's generally better to use becomeForward: unless you have a really good reason to use become:  and it's generally better to use anything other than becomeForward: if you can. It's what dubya would call "the nukular opshin"

Reply | Threaded
Open this post in threaded view
|

Re: Finding all references to an object

Marcus Denker-4
In reply to this post by Sean P. DeNigris

On Aug 3, 2011, at 8:45 AM, Pat Maddox wrote:

> On Aug 2, 2011, at 11:40 PM, Sean P. DeNigris wrote:
>
>>
>> Pat Maddox-3 wrote:
>>>
>>> become: swaps the two objects entirely, becomeForward: "replaces"
>>> references with the argument.
>>>
>>
>> Got it, thanks. The system tests (duh) for these are really clear.
>
> it's generally better to use becomeForward: unless you have a really good reason to use become:  and it's generally better to use anything other than becomeForward: if you can. It's what dubya would call "the nukular opshin"
>

And you need to take care: #become can be very slow. It can (if not both objects are in the newspace of the GC) require to scan the *whole* memory.
This is slow and performance degrades the more memory you use.

The "fast bulk become" that is sometimes listed as a major innovation of the squeak vm is only related to becomming multiple objects: you can
become a group of objects and traverse the memory only once. But as it does scan the whole memory.

The sad thing is that a fast become would be really nice for many things... e.g. if you want to do highly dynamic stuff with proxies. Making
objects remote, swap them, or have proxies for objects-not-yet there (futures)...

But in practice #become is far too slow for these. We should change that.

        Marcus

--
Marcus Denker -- http://marcusdenker.de


Reply | Threaded
Open this post in threaded view
|

Re: Finding all references to an object

Sean P. DeNigris
Administrator
Marcus Denker-4 wrote
you need to take care: #become can be very slow.
Thanks for pointing that out. I'm finding a need for it, not in production, but as I eat my own dog food playing with my evolving systems, so speed is not an issue.

Sean
Cheers,
Sean