[Reflectivity] Links on Slots

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

[Reflectivity] Links on Slots

Marcus Denker-4
Hi,

basis for annotating instanceVariables (Slots) with meta links is now working.
        https://pharo.fogbugz.com/f/cases/16669/MetaLinks-on-Slots

This test is green:

testReifySlotName
    | iVar instance link |
    iVar := ReflectivityExamples slotNamed: #ivar.

    link := MetaLink new
        metaObject: self;
        selector: #tagExec:;
        arguments: #(name).

    iVar link: link.
    self assert: iVar hasMetalink.
    self assert: (ReflectivityExamples >> #exampleIvarRead) class = ReflectiveMethod.
    self assert: (tag isNil).
    instance := ReflectivityExamples new.
    self assert: (instance exampleIvarRead = 33).
    self assert: (tag = #ivar).
    link uninstall.




Reply | Threaded
Open this post in threaded view
|

Re: [Reflectivity] Links on Slots

Tudor Girba-2
Yuppee! This means that we can now implement an inspector refresh properly, right?

Cheers,
Doru


On Wed, Sep 30, 2015 at 11:49 AM, Marcus Denker <[hidden email]> wrote:
Hi,

basis for annotating instanceVariables (Slots) with meta links is now working.
        https://pharo.fogbugz.com/f/cases/16669/MetaLinks-on-Slots

This test is green:

testReifySlotName
    | iVar instance link |
    iVar := ReflectivityExamples slotNamed: #ivar.

    link := MetaLink new
        metaObject: self;
        selector: #tagExec:;
        arguments: #(name).

    iVar link: link.
    self assert: iVar hasMetalink.
    self assert: (ReflectivityExamples >> #exampleIvarRead) class = ReflectiveMethod.
    self assert: (tag isNil).
    instance := ReflectivityExamples new.
    self assert: (instance exampleIvarRead = 33).
    self assert: (tag = #ivar).
    link uninstall.







--

"Every thing has its own flow"
Reply | Threaded
Open this post in threaded view
|

Re: [Reflectivity] Links on Slots

Marcus Denker-4

On 30 Sep 2015, at 17:23, Tudor Girba <[hidden email]> wrote:

Yuppee! This means that we can now implement an inspector refresh properly, right?


The only problem is that the change is only active for new method invocations… so there might be
cases where it would not update if the change is done in a loop, for example, and active on the stack
already…

Cheers,
Doru


On Wed, Sep 30, 2015 at 11:49 AM, Marcus Denker <[hidden email]> wrote:
Hi,

basis for annotating instanceVariables (Slots) with meta links is now working.
        https://pharo.fogbugz.com/f/cases/16669/MetaLinks-on-Slots

This test is green:

testReifySlotName
    | iVar instance link |
    iVar := ReflectivityExamples slotNamed: #ivar.

    link := MetaLink new
        metaObject: self;
        selector: #tagExec:;
        arguments: #(name).

    iVar link: link.
    self assert: iVar hasMetalink.
    self assert: (ReflectivityExamples >> #exampleIvarRead) class = ReflectiveMethod.
    self assert: (tag isNil).
    instance := ReflectivityExamples new.
    self assert: (instance exampleIvarRead = 33).
    self assert: (tag = #ivar).
    link uninstall.







--

"Every thing has its own flow"

Reply | Threaded
Open this post in threaded view
|

Re: [Reflectivity] Links on Slots

Tudor Girba-2
Hi,

I think this should be Ok for most inspector cases because we rarely open the object in the middle of a method and expect it to be updated within that same method. Or did I get it wrong?

Cheers,
Doru



On Wed, Sep 30, 2015 at 5:31 PM, Marcus Denker <[hidden email]> wrote:

On 30 Sep 2015, at 17:23, Tudor Girba <[hidden email]> wrote:

Yuppee! This means that we can now implement an inspector refresh properly, right?


The only problem is that the change is only active for new method invocations… so there might be
cases where it would not update if the change is done in a loop, for example, and active on the stack
already…

Cheers,
Doru


On Wed, Sep 30, 2015 at 11:49 AM, Marcus Denker <[hidden email]> wrote:
Hi,

basis for annotating instanceVariables (Slots) with meta links is now working.
        https://pharo.fogbugz.com/f/cases/16669/MetaLinks-on-Slots

This test is green:

testReifySlotName
    | iVar instance link |
    iVar := ReflectivityExamples slotNamed: #ivar.

    link := MetaLink new
        metaObject: self;
        selector: #tagExec:;
        arguments: #(name).

    iVar link: link.
    self assert: iVar hasMetalink.
    self assert: (ReflectivityExamples >> #exampleIvarRead) class = ReflectiveMethod.
    self assert: (tag isNil).
    instance := ReflectivityExamples new.
    self assert: (instance exampleIvarRead = 33).
    self assert: (tag = #ivar).
    link uninstall.







--

"Every thing has its own flow"




--

"Every thing has its own flow"
Reply | Threaded
Open this post in threaded view
|

Re: [Reflectivity] Links on Slots

Marcus Denker-4

> On 30 Sep 2015, at 17:45, Tudor Girba <[hidden email]> wrote:
>
> Hi,
>
> I think this should be Ok for most inspector cases because we rarely open the object in the middle of a method and expect it to be updated within that same method. Or did I get it wrong?
>

if you want to do change tracking by interception all writes, than any update in a loop (that accesses the ivar directly) that is active already before the inspector is opened would be not seen.

I do not think this happens often.

Possible solutions:

- detect this case “there is method on the stack accessing this ivar —> do slow update, or display a warning that automatic update might not work)
- Implement on-stack replacement for e.g. just #before links…
- use another mechanism to detect state change

        Marcus