MetaLink>>level: failing?
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
On 25 Oct 2018, at 01:33, Vitor Medina Cruz <vitormcruz@gmail.com> 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
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 <marcus.denker@inria.fr> wrote:
On 25 Oct 2018, at 01:33, Vitor Medina Cruz <vitormcruz@gmail.com> 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
Hello, I added a fist issue (and fix) for parts of the problem https://pharo.fogbugz.com/f/cases/22641/Semantic-analysis-needs-to-take-inst... https://github.com/pharo-project/pharo/pull/1960 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 <vitormcruz@gmail.com> 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 <marcus.denker@inria.fr <mailto:marcus.denker@inria.fr>> wrote:
On 25 Oct 2018, at 01:33, Vitor Medina Cruz <vitormcruz@gmail.com <mailto:vitormcruz@gmail.com>> 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
Hi, I added https://pharo.fogbugz.com/f/cases/22642/instead-links-and-meta-level-origina... 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 <marcus.denker@inria.fr> wrote:
Hello,
I added a fist issue (and fix) for parts of the problem
https://pharo.fogbugz.com/f/cases/22641/Semantic-analysis-needs-to-take-inst... <https://pharo.fogbugz.com/f/cases/22641/Semantic-analysis-needs-to-take-inst...> https://github.com/pharo-project/pharo/pull/1960 <https://github.com/pharo-project/pharo/pull/1960>
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 <vitormcruz@gmail.com <mailto:vitormcruz@gmail.com>> 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 <marcus.denker@inria.fr <mailto:marcus.denker@inria.fr>> wrote:
On 25 Oct 2018, at 01:33, Vitor Medina Cruz <vitormcruz@gmail.com <mailto:vitormcruz@gmail.com>> 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
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 <marcus.denker@inria.fr> wrote:
Hi,
I added
https://pharo.fogbugz.com/f/cases/22642/instead-links-and-meta-level-origina... <https://pharo.fogbugz.com/f/cases/22642/instead-links-and-meta-level-origina...>
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 <marcus.denker@inria.fr <mailto:marcus.denker@inria.fr>> wrote:
Hello,
I added a fist issue (and fix) for parts of the problem
https://pharo.fogbugz.com/f/cases/22641/Semantic-analysis-needs-to-take-inst... <https://pharo.fogbugz.com/f/cases/22641/Semantic-analysis-needs-to-take-inst...> https://github.com/pharo-project/pharo/pull/1960 <https://github.com/pharo-project/pharo/pull/1960>
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 <vitormcruz@gmail.com <mailto:vitormcruz@gmail.com>> 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 <marcus.denker@inria.fr <mailto:marcus.denker@inria.fr>> wrote:
On 25 Oct 2018, at 01:33, Vitor Medina Cruz <vitormcruz@gmail.com <mailto:vitormcruz@gmail.com>> 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
It works like a charm now!!! Thanks! On Tue, Nov 13, 2018 at 11:23 AM Marcus Denker <marcus.denker@inria.fr> 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 <marcus.denker@inria.fr> wrote:
Hi,
I added
https://pharo.fogbugz.com/f/cases/22642/instead-links-and-meta-level-origina...
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 <marcus.denker@inria.fr> wrote:
Hello,
I added a fist issue (and fix) for parts of the problem
https://pharo.fogbugz.com/f/cases/22641/Semantic-analysis-needs-to-take-inst... https://github.com/pharo-project/pharo/pull/1960
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 <vitormcruz@gmail.com> 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 <marcus.denker@inria.fr> wrote:
On 25 Oct 2018, at 01:33, Vitor Medina Cruz <vitormcruz@gmail.com> 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
participants (2)
-
Marcus Denker -
Vitor Medina Cruz