MetaLink>>level: failing?

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

MetaLink>>level: failing?

Vitor Medina Cruz
Hello,

I am playing with MetaLink, really cool!, but I am having issues that I am unsure if it's some erro or if I am doing something wrong (I am using Pharo 6.1 32 bits in windows.). Consider:

TestMetaLink>>execute
    UIManager default alert: 'Actual Version'.

And in Playground:

| link |

link := MetaLink new metaObject: [ :object | UIManager default alert: 'Linked Version' ];       
                selector: #value:;
                 arguments: #(#object);
                 control: #instead.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

This works as expected, an alert with 'Linked Version' is promped. But then suppose I want to execute the actual node alongside with the linked one considering some condition:

| link choice |

choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments |
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ object perform: selector withArguments: arguments].
                                           ];        
                selector: #value:value:value:;
                 arguments: #(#object #selector #arguments);
                 control: #instead;
                 level: 0.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

As I understand, level:0 is necessary in order to avoid an infinite loop, but then I get an error:

KeyNotFound: key #RFArgumentsReificationVar not found in Dictionary

Am I doing something wrong? Is that an error?

Best Regards,
Vitor
Reply | Threaded
Open this post in threaded view
|

Re: MetaLink>>level: failing?

Marcus Denker-4


On 25 Oct 2018, at 01:33, Vitor Medina Cruz <[hidden email]> wrote:

Hello,

I am playing with MetaLink, really cool!, but I am having issues that I am unsure if it's some erro or if I am doing something wrong (I am using Pharo 6.1 32 bits in windows.). Consider:

TestMetaLink>>execute
    UIManager default alert: 'Actual Version'.

And in Playground:

| link |

link := MetaLink new metaObject: [ :object | UIManager default alert: 'Linked Version' ];       
                selector: #value:;
                 arguments: #(#object);
                 control: #instead.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

This works as expected, an alert with 'Linked Version' is promped. But then suppose I want to execute the actual node alongside with the linked one considering some condition:

| link choice |

choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments |
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ object perform: selector withArguments: arguments].
                                           ];        
                selector: #value:value:value:;
                 arguments: #(#object #selector #arguments);
                 control: #instead;
                 level: 0.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

As I understand, level:0 is necessary in order to avoid an infinite loop, but then I get an error:

KeyNotFound: key #RFArgumentsReificationVar not found in Dictionary

Am I doing something wrong? Is that an error?

Hello,

Yes, this looks like a bug. I will fix it over the next days.

Marcus







Reply | Threaded
Open this post in threaded view
|

Re: MetaLink>>level: failing?

Vitor Medina Cruz
Thanks! Is there an issue on fogbuzz where I can be notified of resolution? Do you need me to create it?

After that how can update the code? Software update is safe or should I create a new image?

regards,
Vitor

On Mon, Oct 29, 2018 at 12:08 PM Marcus Denker <[hidden email]> wrote:


On 25 Oct 2018, at 01:33, Vitor Medina Cruz <[hidden email]> wrote:

Hello,

I am playing with MetaLink, really cool!, but I am having issues that I am unsure if it's some erro or if I am doing something wrong (I am using Pharo 6.1 32 bits in windows.). Consider:

TestMetaLink>>execute
    UIManager default alert: 'Actual Version'.

And in Playground:

| link |

link := MetaLink new metaObject: [ :object | UIManager default alert: 'Linked Version' ];       
                selector: #value:;
                 arguments: #(#object);
                 control: #instead.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

This works as expected, an alert with 'Linked Version' is promped. But then suppose I want to execute the actual node alongside with the linked one considering some condition:

| link choice |

choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments |
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ object perform: selector withArguments: arguments].
                                           ];        
                selector: #value:value:value:;
                 arguments: #(#object #selector #arguments);
                 control: #instead;
                 level: 0.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

As I understand, level:0 is necessary in order to avoid an infinite loop, but then I get an error:

KeyNotFound: key #RFArgumentsReificationVar not found in Dictionary

Am I doing something wrong? Is that an error?

Hello,

Yes, this looks like a bug. I will fix it over the next days.

Marcus







Reply | Threaded
Open this post in threaded view
|

Re: MetaLink>>level: failing?

Marcus Denker-4
Hello,

I added a fist issue (and fix) for parts of the problem


But after this, it does not work as the level just turns off calling the meta level code, but does not execute the
original code where the #instead is put.
(#instead in general needs more work in this implementation).

I will open another issue for that.

Marcus

On 31 Oct 2018, at 18:03, Vitor Medina Cruz <[hidden email]> wrote:

Thanks! Is there an issue on fogbuzz where I can be notified of resolution? Do you need me to create it?

After that how can update the code? Software update is safe or should I create a new image?

regards,
Vitor

On Mon, Oct 29, 2018 at 12:08 PM Marcus Denker <[hidden email]> wrote:


On 25 Oct 2018, at 01:33, Vitor Medina Cruz <[hidden email]> wrote:

Hello,

I am playing with MetaLink, really cool!, but I am having issues that I am unsure if it's some erro or if I am doing something wrong (I am using Pharo 6.1 32 bits in windows.). Consider:

TestMetaLink>>execute
    UIManager default alert: 'Actual Version'.

And in Playground:

| link |

link := MetaLink new metaObject: [ :object | UIManager default alert: 'Linked Version' ];       
                selector: #value:;
                 arguments: #(#object);
                 control: #instead.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

This works as expected, an alert with 'Linked Version' is promped. But then suppose I want to execute the actual node alongside with the linked one considering some condition:

| link choice |

choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments |
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ object perform: selector withArguments: arguments].
                                           ];        
                selector: #value:value:value:;
                 arguments: #(#object #selector #arguments);
                 control: #instead;
                 level: 0.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

As I understand, level:0 is necessary in order to avoid an infinite loop, but then I get an error:

KeyNotFound: key #RFArgumentsReificationVar not found in Dictionary

Am I doing something wrong? Is that an error?

Hello,

Yes, this looks like a bug. I will fix it over the next days.

Marcus








Reply | Threaded
Open this post in threaded view
|

Re: MetaLink>>level: failing?

Marcus Denker-4
Hi,

I added 


as a workaround, you can use a #before link with an explicit return:


choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments :context | 
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ context sender sender sender sender return: (object perform: selector withArguments: arguments)].
                                           ];         
                selector: #value:value:value:value:;
                 arguments: #(#object #selector #arguments #context);
                 control: #before;
 level: 0.

(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

(yes, the  context sender sender sender  shows that #context needs to do the right thing when using  level: 0. or not… another thing to fix)

Marcus

On 7 Nov 2018, at 15:08, Marcus Denker <[hidden email]> wrote:

Hello,

I added a fist issue (and fix) for parts of the problem


But after this, it does not work as the level just turns off calling the meta level code, but does not execute the
original code where the #instead is put.
(#instead in general needs more work in this implementation).

I will open another issue for that.

Marcus

On 31 Oct 2018, at 18:03, Vitor Medina Cruz <[hidden email]> wrote:

Thanks! Is there an issue on fogbuzz where I can be notified of resolution? Do you need me to create it?

After that how can update the code? Software update is safe or should I create a new image?

regards,
Vitor

On Mon, Oct 29, 2018 at 12:08 PM Marcus Denker <[hidden email]> wrote:


On 25 Oct 2018, at 01:33, Vitor Medina Cruz <[hidden email]> wrote:

Hello,

I am playing with MetaLink, really cool!, but I am having issues that I am unsure if it's some erro or if I am doing something wrong (I am using Pharo 6.1 32 bits in windows.). Consider:

TestMetaLink>>execute
    UIManager default alert: 'Actual Version'.

And in Playground:

| link |

link := MetaLink new metaObject: [ :object | UIManager default alert: 'Linked Version' ];       
                selector: #value:;
                 arguments: #(#object);
                 control: #instead.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

This works as expected, an alert with 'Linked Version' is promped. But then suppose I want to execute the actual node alongside with the linked one considering some condition:

| link choice |

choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments |
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ object perform: selector withArguments: arguments].
                                           ];        
                selector: #value:value:value:;
                 arguments: #(#object #selector #arguments);
                 control: #instead;
                 level: 0.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

As I understand, level:0 is necessary in order to avoid an infinite loop, but then I get an error:

KeyNotFound: key #RFArgumentsReificationVar not found in Dictionary

Am I doing something wrong? Is that an error?

Hello,

Yes, this looks like a bug. I will fix it over the next days.

Marcus









Reply | Threaded
Open this post in threaded view
|

Re: MetaLink>>level: failing?

Marcus Denker-4
More progress… in the latest Pharo7 this is now working... (#operation reifies the original operation):

| link choice | 

choice := true.
link := MetaLink new metaObject: [ :operation | 
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [operation value ].
                                           ];         
                selector: #value:;
                arguments: #(#operation);
                control: #instead.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

No need for using #level: as #operation for method execution is reifying the *original* method that would have been executed without the link.

(this then is, too, what will be used to make finally “turning off” instead links work correctly: if the instead link is not active (due to a condition or level), it will
instead execute “operation value”, that is, what would have been done without the #instead link present.

Marcus

On 7 Nov 2018, at 15:47, Marcus Denker <[hidden email]> wrote:

Hi,

I added 


as a workaround, you can use a #before link with an explicit return:


choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments :context | 
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ context sender sender sender sender return: (object perform: selector withArguments: arguments)].
                                           ];         
                selector: #value:value:value:value:;
                 arguments: #(#object #selector #arguments #context);
                 control: #before;
 level: 0.

(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

(yes, the  context sender sender sender  shows that #context needs to do the right thing when using  level: 0. or not… another thing to fix)

Marcus

On 7 Nov 2018, at 15:08, Marcus Denker <[hidden email]> wrote:

Hello,

I added a fist issue (and fix) for parts of the problem


But after this, it does not work as the level just turns off calling the meta level code, but does not execute the
original code where the #instead is put.
(#instead in general needs more work in this implementation).

I will open another issue for that.

Marcus

On 31 Oct 2018, at 18:03, Vitor Medina Cruz <[hidden email]> wrote:

Thanks! Is there an issue on fogbuzz where I can be notified of resolution? Do you need me to create it?

After that how can update the code? Software update is safe or should I create a new image?

regards,
Vitor

On Mon, Oct 29, 2018 at 12:08 PM Marcus Denker <[hidden email]> wrote:


On 25 Oct 2018, at 01:33, Vitor Medina Cruz <[hidden email]> wrote:

Hello,

I am playing with MetaLink, really cool!, but I am having issues that I am unsure if it's some erro or if I am doing something wrong (I am using Pharo 6.1 32 bits in windows.). Consider:

TestMetaLink>>execute
    UIManager default alert: 'Actual Version'.

And in Playground:

| link |

link := MetaLink new metaObject: [ :object | UIManager default alert: 'Linked Version' ];       
                selector: #value:;
                 arguments: #(#object);
                 control: #instead.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

This works as expected, an alert with 'Linked Version' is promped. But then suppose I want to execute the actual node alongside with the linked one considering some condition:

| link choice |

choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments |
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ object perform: selector withArguments: arguments].
                                           ];        
                selector: #value:value:value:;
                 arguments: #(#object #selector #arguments);
                 control: #instead;
                 level: 0.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

As I understand, level:0 is necessary in order to avoid an infinite loop, but then I get an error:

KeyNotFound: key #RFArgumentsReificationVar not found in Dictionary

Am I doing something wrong? Is that an error?

Hello,

Yes, this looks like a bug. I will fix it over the next days.

Marcus










Reply | Threaded
Open this post in threaded view
|

Re: MetaLink>>level: failing?

Vitor Medina Cruz
It works like a charm now!!! Thanks!

On Tue, Nov 13, 2018 at 11:23 AM Marcus Denker <[hidden email]> wrote:
More progress… in the latest Pharo7 this is now working... (#operation reifies the original operation):

| link choice | 

choice := true.
link := MetaLink new metaObject: [ :operation | 
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [operation value ].
                                           ];         
                selector: #value:;
                arguments: #(#operation);
                control: #instead.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

No need for using #level: as #operation for method execution is reifying the *original* method that would have been executed without the link.

(this then is, too, what will be used to make finally “turning off” instead links work correctly: if the instead link is not active (due to a condition or level), it will
instead execute “operation value”, that is, what would have been done without the #instead link present.

Marcus

On 7 Nov 2018, at 15:47, Marcus Denker <[hidden email]> wrote:

Hi,

I added 


as a workaround, you can use a #before link with an explicit return:


choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments :context | 
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ context sender sender sender sender return: (object perform: selector withArguments: arguments)].
                                           ];         
                selector: #value:value:value:value:;
                 arguments: #(#object #selector #arguments #context);
                 control: #before;
 level: 0.

(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

(yes, the  context sender sender sender  shows that #context needs to do the right thing when using  level: 0. or not… another thing to fix)

Marcus

On 7 Nov 2018, at 15:08, Marcus Denker <[hidden email]> wrote:

Hello,

I added a fist issue (and fix) for parts of the problem


But after this, it does not work as the level just turns off calling the meta level code, but does not execute the
original code where the #instead is put.
(#instead in general needs more work in this implementation).

I will open another issue for that.

Marcus

On 31 Oct 2018, at 18:03, Vitor Medina Cruz <[hidden email]> wrote:

Thanks! Is there an issue on fogbuzz where I can be notified of resolution? Do you need me to create it?

After that how can update the code? Software update is safe or should I create a new image?

regards,
Vitor

On Mon, Oct 29, 2018 at 12:08 PM Marcus Denker <[hidden email]> wrote:


On 25 Oct 2018, at 01:33, Vitor Medina Cruz <[hidden email]> wrote:

Hello,

I am playing with MetaLink, really cool!, but I am having issues that I am unsure if it's some erro or if I am doing something wrong (I am using Pharo 6.1 32 bits in windows.). Consider:

TestMetaLink>>execute
    UIManager default alert: 'Actual Version'.

And in Playground:

| link |

link := MetaLink new metaObject: [ :object | UIManager default alert: 'Linked Version' ];       
                selector: #value:;
                 arguments: #(#object);
                 control: #instead.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

This works as expected, an alert with 'Linked Version' is promped. But then suppose I want to execute the actual node alongside with the linked one considering some condition:

| link choice |

choice := true.
link := MetaLink new metaObject: [ :object :selector :arguments |
                                              UIManager default alert: 'Linked Version'.
                                              choice ifTrue: [ object perform: selector withArguments: arguments].
                                           ];        
                selector: #value:value:value:;
                 arguments: #(#object #selector #arguments);
                 control: #instead;
                 level: 0.


(TestMetaLink >> #execute) ast link: link.
TestMetaLink new execute.
link uninstall.

As I understand, level:0 is necessary in order to avoid an infinite loop, but then I get an error:

KeyNotFound: key #RFArgumentsReificationVar not found in Dictionary

Am I doing something wrong? Is that an error?

Hello,

Yes, this looks like a bug. I will fix it over the next days.

Marcus