Recursion inside #doesNotUnderstand: method. Why?

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

Recursion inside #doesNotUnderstand: method. Why?

Denis Kudriashov
Hi.

Does anybody know why #doesNotUnderstand: is implemented with recursion at the end?

doesNotUnderstand: aMessage 
| exception resumeValue |
(exception := MessageNotUnderstood new)
message: aMessage;
receiver: self.
resumeValue := exception signal.
^exception reachedDefaultHandler
ifTrue: [aMessage sentTo: self]
ifFalse: [resumeValue].

Best regards,
Denis
Reply | Threaded
Open this post in threaded view
|

Re: Recursion inside #doesNotUnderstand: method. Why?

Denis Kudriashov
Maybe in past it was used to create methods in debugger on the fly. But now it is not.
I just check it. I removed recursion logic and methods creation continue working in debugger. Maybe we should remove this strange behaviour

2016-02-25 17:56 GMT+01:00 Denis Kudriashov <[hidden email]>:
Hi.

Does anybody know why #doesNotUnderstand: is implemented with recursion at the end?

doesNotUnderstand: aMessage 
| exception resumeValue |
(exception := MessageNotUnderstood new)
message: aMessage;
receiver: self.
resumeValue := exception signal.
^exception reachedDefaultHandler
ifTrue: [aMessage sentTo: self]
ifFalse: [resumeValue].

Best regards,
Denis

Reply | Threaded
Open this post in threaded view
|

Re: Recursion inside #doesNotUnderstand: method. Why?

Blondeau Vincent
In reply to this post by Denis Kudriashov

Hi,

 

Because when you are receiving a DNU, you have the possibility to implement the method before resuming the exception.

If you choose to implement the method, the message is sent again to the newly created method and the execution restarts.

 

Vincent

 

 

De : Pharo-dev [mailto:[hidden email]] De la part de Denis Kudriashov
Envoyé : jeudi 25 février 2016 17:56
À : Discusses Development of Pharo
Objet : [Pharo-dev] Recursion inside #doesNotUnderstand: method. Why?

 

Hi.

 

Does anybody know why #doesNotUnderstand: is implemented with recursion at the end?

 

doesNotUnderstand: aMessage                     

            | exception resumeValue |

            (exception := MessageNotUnderstood new)

                        message: aMessage;

                        receiver: self.

            resumeValue := exception signal.

            ^exception reachedDefaultHandler

                        ifTrue: [aMessage sentTo: self]

                        ifFalse: [resumeValue].

 

Best regards,

Denis


!!!*************************************************************************************
"Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité de Worldline ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Worldline liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.!!!"
Reply | Threaded
Open this post in threaded view
|

Re: Recursion inside #doesNotUnderstand: method. Why?

Aliaksei Syrel
In reply to this post by Denis Kudriashov
Just a guess, maybe to allow method adding from debugger and then ability to continue execution?

Cheers,
Alex

On Thu, Feb 25, 2016 at 5:56 PM, Denis Kudriashov <[hidden email]> wrote:
Hi.

Does anybody know why #doesNotUnderstand: is implemented with recursion at the end?

doesNotUnderstand: aMessage 
| exception resumeValue |
(exception := MessageNotUnderstood new)
message: aMessage;
receiver: self.
resumeValue := exception signal.
^exception reachedDefaultHandler
ifTrue: [aMessage sentTo: self]
ifFalse: [resumeValue].

Best regards,
Denis

Reply | Threaded
Open this post in threaded view
|

Re: Recursion inside #doesNotUnderstand: method. Why?

Eliot Miranda-2
In reply to this post by Denis Kudriashov
Hi Denis,


On Thu, Feb 25, 2016 at 8:56 AM, Denis Kudriashov <[hidden email]> wrote:
Hi.

Does anybody know why #doesNotUnderstand: is implemented with recursion at the end?

doesNotUnderstand: aMessage 
| exception resumeValue |
(exception := MessageNotUnderstood new)
message: aMessage;
receiver: self.
resumeValue := exception signal.
^exception reachedDefaultHandler
ifTrue: [aMessage sentTo: self]
ifFalse: [resumeValue].

It's so that when a doesNotUnderstand: occurs and one implements the method in the debugger one can proceed.  The sentTo: at the end will now invoke the newly defined method and one can continue programming.

Best regards,
Denis

_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: Recursion inside #doesNotUnderstand: method. Why?

Nicolai Hess-3-2
In reply to this post by Aliaksei Syrel


Am 25.02.2016 6:30 nachm. schrieb "Aliaksei Syrel" <[hidden email]>:
>
> Just a guess, maybe to allow method adding from debugger and then ability to continue execution?
>
> Cheers,
> Alex
>
> On Thu, Feb 25, 2016 at 5:56 PM, Denis Kudriashov <[hidden email]> wrote:
>>
>> Hi.
>>
>> Does anybody know why #doesNotUnderstand: is implemented with recursion at the end?
>>
>>> doesNotUnderstand: aMessage 
>>> | exception resumeValue |
>>> (exception := MessageNotUnderstood new)
>>> message: aMessage;
>>> receiver: self.
>>> resumeValue := exception signal.
>>> ^exception reachedDefaultHandler
>>> ifTrue: [aMessage sentTo: self]
>>> ifFalse: [resumeValue].
>>

There is a difference between
sentTo:
and
sendTo:

>>
>> Best regards,
>> Denis
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Recursion inside #doesNotUnderstand: method. Why?

Blondeau Vincent
In reply to this post by Denis Kudriashov

I don’t think so:

 

Put a halt here:

…ifTrue: [self halt. aMessage sentTo: self]…

 

1.       Open a playground

2.       Do: Object new toto

You should have a debugger that pops. Don’t close it.

3.       Go in Nautilus, implement toto on Object

4.       Click on proceed in the debugger.

You should have a Halt instead. And if you click on proceed  again, it should execute the toto method.

So it is used, and I frequently use it.

 

Cheers,

Vincent

 

De : Pharo-dev [mailto:[hidden email]] De la part de Denis Kudriashov
Envoyé : jeudi 25 février 2016 18:06
À : Discusses Development of Pharo
Objet : Re: [Pharo-dev] Recursion inside #doesNotUnderstand: method. Why?

 

Maybe in past it was used to create methods in debugger on the fly. But now it is not.

I just check it. I removed recursion logic and methods creation continue working in debugger. Maybe we should remove this strange behaviour

 

2016-02-25 17:56 GMT+01:00 Denis Kudriashov <[hidden email]>:

Hi.

 

Does anybody know why #doesNotUnderstand: is implemented with recursion at the end?

 

doesNotUnderstand: aMessage 

| exception resumeValue |

(exception := MessageNotUnderstood new)

message: aMessage;

receiver: self.

resumeValue := exception signal.

^exception reachedDefaultHandler

ifTrue: [aMessage sentTo: self]

ifFalse: [resumeValue].

 

Best regards,

Denis

 


!!!*************************************************************************************
"Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité de Worldline ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Worldline liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.!!!"
Reply | Threaded
Open this post in threaded view
|

Re: Recursion inside #doesNotUnderstand: method. Why?

Denis Kudriashov
In reply to this post by Eliot Miranda-2

2016-02-25 18:24 GMT+01:00 Eliot Miranda <[hidden email]>:
It's so that when a doesNotUnderstand: occurs and one implements the method in the debugger one can proceed.  The sentTo: at the end will now invoke the newly defined method and one can continue programming.

But as I said I make experiment. And in Pharo this recursion is not needed to implement unknown messages in Debugger. But for case of Vincent it is needed

Reply | Threaded
Open this post in threaded view
|

Re: Recursion inside #doesNotUnderstand: method. Why?

Eliot Miranda-2


On Feb 26, 2016, at 9:12 AM, Denis Kudriashov <[hidden email]> wrote:


2016-02-25 18:24 GMT+01:00 Eliot Miranda <[hidden email]>:
It's so that when a doesNotUnderstand: occurs and one implements the method in the debugger one can proceed.  The sentTo: at the end will now invoke the newly defined method and one can continue programming.

But as I said I make experiment. And in Pharo this recursion is not needed to implement unknown messages in Debugger. But for case of Vincent it is needed

Which implies that the debugger is doing something unnecessary.  Instead of creating an activation of the newly defined message it could simply proceed?

_,,,^..^,,,_ (phone)