[Pharo-dev] unwinding the stack

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

[Pharo-dev] unwinding the stack

Stéphane Ducasse
Hi guys

I'm trying to explain the following sentence (I wrote long time ago) and now I'm stuck

"escaping blocks jump to their home contexts but do not unwind the stack after this point"

especially I'm not clear anymore on the unwind the stack.

Stef
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] unwinding the stack

camille teruel

On 22 juil. 2013, at 22:58, Stéphane Ducasse wrote:

Hi guys

I'm trying to explain the following sentence (I wrote long time ago) and now I'm stuck

"escaping blocks jump to their home contexts but do not unwind the stack after this point"

especially I'm not clear anymore on the unwind the stack.

Maybe you meant that escaping blocks unwind the stack *up to* their home context.


Stef

Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] unwinding the stack

Eliot Miranda-2
In reply to this post by Stéphane Ducasse


On Mon, Jul 22, 2013 at 1:58 PM, Stéphane Ducasse <[hidden email]> wrote:
Hi guys

I'm trying to explain the following sentence (I wrote long time ago) and now I'm stuck

"escaping blocks jump to their home contexts but do not unwind the stack after this point"

Seems wrong to me.  ^-returns in blocks return to the sender of the home context.

 
especially I'm not clear anymore on the unwind the stack.

The stack is unwound either by the VM executing the ^-return or by MethodCOntext>>#return:, sent from #aboutToReturn:to: if the ^-return found an intervening unwind context.  (The VM sends aboutToReturn:to:).
 

HTH
Eliot


Stef



--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] unwinding the stack

Stéphane Ducasse

On Jul 23, 2013, at 12:25 AM, Eliot Miranda <[hidden email]> wrote:



On Mon, Jul 22, 2013 at 1:58 PM, Stéphane Ducasse <[hidden email]> wrote:
Hi guys

I'm trying to explain the following sentence (I wrote long time ago) and now I'm stuck

"escaping blocks jump to their home contexts but do not unwind the stack after this point"

Seems wrong to me.  ^-returns in blocks return to the sender of the home context.

Yes I thought so too. I will remove this sentence because it is blurry and wrong. I thought I was wrong. 
 
especially I'm not clear anymore on the unwind the stack.

The stack is unwound either by the VM executing the ^-return or by MethodCOntext>>#return:, sent from #aboutToReturn:to: if the ^-return found an intervening unwind context.  (The VM sends aboutToReturn:to:).

Thanks 
what is a intervening unwind context?

 

HTH
Eliot


Stef



--
best,
Eliot

Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] unwinding the stack

Clément Béra
2013/7/23 Stéphane Ducasse <[hidden email]>

On Jul 23, 2013, at 12:25 AM, Eliot Miranda <[hidden email]> wrote:



On Mon, Jul 22, 2013 at 1:58 PM, Stéphane Ducasse <[hidden email]> wrote:
Hi guys

I'm trying to explain the following sentence (I wrote long time ago) and now I'm stuck

"escaping blocks jump to their home contexts but do not unwind the stack after this point"

Seems wrong to me.  ^-returns in blocks return to the sender of the home context.

Yes I thought so too. I will remove this sentence because it is blurry and wrong. I thought I was wrong. 
 
especially I'm not clear anymore on the unwind the stack.

The stack is unwound either by the VM executing the ^-return or by MethodCOntext>>#return:, sent from #aboutToReturn:to: if the ^-return found an intervening unwind context.  (The VM sends aboutToReturn:to:).

Thanks 
what is a intervening unwind context?

I'm not sure I understood the question but:

Unwind a context means when you return from a context to an outer one far in the stack you need to check for unwind context (= context with 'ensure:'), and execute the unwind block (= ensure: argument).

For ex:

context 1
context 2
context 3 (marked with primitive as unwind context)
context 4
context 5 Non local return to context 1

Here the non local return in context 5 goes back to context 1 skipping the rest of the execution of the context 2 - 3 - 4. While going back to context 1 it checks every context (2, 3, 4), detects context 3 as unwindcontext and executes the unwind block of context 3 before continuing the execution in context 1. 
 

 

HTH
Eliot


Stef



--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] unwinding the stack

Stéphane Ducasse

Thanks 
what is a intervening unwind context?

I'm not sure I understood the question but:

Unwind a context means when you return from a context to an outer one far in the stack you need to check for unwind context (= context with 'ensure:'), and execute the unwind block (= ensure: argument).

Ok this was what I forgot!.
Got it.


For ex:

context 1
context 2
context 3 (marked with primitive as unwind context)
context 4
context 5 Non local return to context 1

Here the non local return in context 5 goes back to context 1 skipping the rest of the execution of the context 2 - 3 - 4. While going back to context 1 it checks every context (2, 3, 4), detects context 3 as unwindcontext and executes the unwind block of context 3 before continuing the execution in context 1. 

Excellent.
Yes I forgot and I guess that we wrote that somehow in the exception chapter.

Stef

 

 

HTH
Eliot


Stef



--
best,
Eliot