ProfStef, Lesson 25 - Unknown selector

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

ProfStef, Lesson 25 - Unknown selector

bahman
Hi all,

Reading ProfStef at lesson 25 (Reflections), when I try to run the last
statement <code>ProfStef default executeMethod: (ProfStef
lookupSelector:#next).</code>, the error pops up saying <error>Unknown
selector executeMethod:</error>.  Am I doing anything wrong?

TIA,

--
Bahman Movaqar  (http://BahmanM.com)

ERP Evaluation, Implementation & Deployment Consultant
PGP Key ID: 0x6AB5BD68 (keyserver2.pgp.com)



signature.asc (565 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

jtuchel
Hi,

I am not sure whether Pharo implements or once implemented a special
method like executeMethod: but in Smalltalk the selector for sending a
message to an object is #perform: so you should probably try to replace
#executeMethod with #perform: .
But I am sure somebody more familiar with ProfStef and Pharo will
comment on your issue more specifically.

HTH,

Joachim

Am 05.11.13 07:36, schrieb Bahman Movaqar:
> Hi all,
>
> Reading ProfStef at lesson 25 (Reflections), when I try to run the last
> statement <code>ProfStef default executeMethod: (ProfStef
> lookupSelector:#next).</code>, the error pops up saying <error>Unknown
> selector executeMethod:</error>.  Am I doing anything wrong?
>
> TIA,
>


Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

Marcus Denker-4
In reply to this post by bahman

On 05 Nov 2013, at 07:36, Bahman Movaqar <[hidden email]> wrote:

executeMethod: (

Hello,

we removed #executeMethod: on Object because it makes no sense as there is an API on the method
for that already. (a good hint for that is that it had no users).

When you want to execute a method directly (not via sending a method), what you have to do:

1) get the method object.
2) tell it to execute itself with #valueWithReceiver:arguments:

so for example:

(Object compiledMethodAt: #halt) valueWithReceiver: nil arguments: #()


We should update ProfStef

Marcus

signature.asc (210 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

Marcus Denker-4

On 05 Nov 2013, at 09:52, Marcus Denker <[hidden email]> wrote:


On 05 Nov 2013, at 07:36, Bahman Movaqar <[hidden email]> wrote:

executeMethod: (

Hello,

we removed #executeMethod: on Object because it makes no sense as there is an API on the method
for that already. (a good hint for that is that it had no users).

When you want to execute a method directly (not via sending a method), what you have to do:

1) get the method object.
2) tell it to execute itself with #valueWithReceiver:arguments:

so for example:

(Object compiledMethodAt: #halt) valueWithReceiver: nil arguments: #()


and there still is

withArgs: argArray executeMethod: compiledMethod

For Object

(which is a primitive)

Marcus

signature.asc (210 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

Clément Béra
In reply to this post by jtuchel
Hello,

The method that exists is #withArgs:executeMethod: so replace 
"executeMethod: someCode" ==> by ==> "withArgs: #( ) executeMethod: someCode"
or create the method:
Object>>executeMethod: compiledMethod
    ^ self withArgs: #( ) executeMethod: compiledMethod
Then it should work.

You're the second one to ask that question I will make a fix. Are you in Pharo 2 or Pharo 3 ?

#perform: is different. #perform: takes a selector as argument and the lookup will find out the method to execute, whereas executeMethod: directly run a method with no lookup (which can lead to a crash if the receiver cannot run properly this method).



2013/11/5 Joachim Tuchel <[hidden email]>
Hi,

I am not sure whether Pharo implements or once implemented a special method like executeMethod: but in Smalltalk the selector for sending a message to an object is #perform: so you should probably try to replace #executeMethod with #perform: .
But I am sure somebody more familiar with ProfStef and Pharo will comment on your issue more specifically.

HTH,

Joachim

Am 05.11.13 07:36, schrieb Bahman Movaqar:

Hi all,

Reading ProfStef at lesson 25 (Reflections), when I try to run the last
statement <code>ProfStef default executeMethod: (ProfStef
lookupSelector:#next).</code>, the error pops up saying <error>Unknown
selector executeMethod:</error>.  Am I doing anything wrong?

TIA,




Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

bahman
On 11/05/2013 12:48, Clément Bera wrote:
Hello,

The method that exists is #withArgs:executeMethod: so replace 
"executeMethod: someCode" ==> by ==> "withArgs: #( ) executeMethod: someCode"
or create the method:
Object>>executeMethod: compiledMethod
    ^ self withArgs: #( ) executeMethod: compiledMethod
Then it should work.

You're the second one to ask that question I will make a fix. Are you in Pharo 2 or Pharo 3 ?

Pharo 2.0.  It's certainly not a stopper as one can always do <code>ProfStef next.</code>.  However since the lesson is about reflection, it somehow feels weird :-)


#perform: is different. #perform: takes a selector as argument and the lookup will find out the method to execute, whereas executeMethod: directly run a method with no lookup (which can lead to a crash if the receiver cannot run properly this method).



2013/11/5 Joachim Tuchel <[hidden email]>
Hi,

I am not sure whether Pharo implements or once implemented a special method like executeMethod: but in Smalltalk the selector for sending a message to an object is #perform: so you should probably try to replace #executeMethod with #perform: .
But I am sure somebody more familiar with ProfStef and Pharo will comment on your issue more specifically.

HTH,

Joachim

Am 05.11.13 07:36, schrieb Bahman Movaqar:

Hi all,

Reading ProfStef at lesson 25 (Reflections), when I try to run the last
statement <code>ProfStef default executeMethod: (ProfStef
lookupSelector:#next).</code>, the error pops up saying <error>Unknown
selector executeMethod:</error>.  Am I doing anything wrong?



-- 
Bahman Movaqar  (http://BahmanM.com)

ERP Evaluation, Implementation & Deployment Consultant
PGP Key ID: 0x6AB5BD68 (keyserver2.pgp.com)

signature.asc (565 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

Marcus Denker-4
In reply to this post by Clément Béra

On 05 Nov 2013, at 10:19, Clément Bera <[hidden email]> wrote:

> Hello,
>
> The method that exists is #withArgs:executeMethod: so replace
> "executeMethod: someCode" ==> by ==> "withArgs: #( ) executeMethod: someCode"
> or create the method:
> Object>>executeMethod: compiledMethod
>     ^ self withArgs: #( ) executeMethod: compiledMethod
> Then it should work.
>

I think the easiest is to add back that methods… I really do not like to have an API on Object
for executing methods (is should be in Method…), but as the primitive is there now, it is not
easy to change.

I all add issues for 2.0 and 3.

        Marcus


Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

Clément Béra
I added the issue with a slice in inbox.


2013/11/5 Marcus Denker <[hidden email]>

On 05 Nov 2013, at 10:19, Clément Bera <[hidden email]> wrote:

> Hello,
>
> The method that exists is #withArgs:executeMethod: so replace
> "executeMethod: someCode" ==> by ==> "withArgs: #( ) executeMethod: someCode"
> or create the method:
> Object>>executeMethod: compiledMethod
>     ^ self withArgs: #( ) executeMethod: compiledMethod
> Then it should work.
>

I think the easiest is to add back that methods… I really do not like to have an API on Object
for executing methods (is should be in Method…), but as the primitive is there now, it is not
easy to change.

I all add issues for 2.0 and 3.

        Marcus



Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

Stéphane Ducasse
In reply to this post by Marcus Denker-4
marcus 

did you open an entry?

Stef

On Nov 5, 2013, at 9:51 AM, Marcus Denker <[hidden email]> wrote:

(Object compiledMethodAt: #halt) valueWithReceiver: nil arguments: #()


We should update ProfStef

Marcus

Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

Marcus Denker-4

On 09 Nov 2013, at 01:30, Stéphane Ducasse <[hidden email]> wrote:

marcus 

did you open an entry?


It is already fixed in 3.0 and 2.0 :-)

Stef

On Nov 5, 2013, at 9:51 AM, Marcus Denker <[hidden email]> wrote:

(Object compiledMethodAt: #halt) valueWithReceiver: nil arguments: #()


We should update ProfStef

Marcus


Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

Clément Béra
In reply to this post by Stéphane Ducasse
This bug is fixed and integrated in Pharo 3.


2013/11/9 Stéphane Ducasse <[hidden email]>
marcus 

did you open an entry?

Stef

On Nov 5, 2013, at 9:51 AM, Marcus Denker <[hidden email]> wrote:

(Object compiledMethodAt: #halt) valueWithReceiver: nil arguments: #()


We should update ProfStef

Marcus


Reply | Threaded
Open this post in threaded view
|

Re: ProfStef, Lesson 25 - Unknown selector

Stéphane Ducasse
In reply to this post by Marcus Denker-4
I do not understand I got many old mails (may be just did not read during the sprint and after I was flying).

Stef
On Nov 9, 2013, at 8:28 AM, Marcus Denker <[hidden email]> wrote:


On 09 Nov 2013, at 01:30, Stéphane Ducasse <[hidden email]> wrote:

marcus 

did you open an entry?


It is already fixed in 3.0 and 2.0 :-)

Stef

On Nov 5, 2013, at 9:51 AM, Marcus Denker <[hidden email]> wrote:

(Object compiledMethodAt: #halt) valueWithReceiver: nil arguments: #()


We should update ProfStef

Marcus