[squeak-dev] Questions about FullBlock closures

Jaromir Matas mail at jaromir.net
Sun Feb 12 13:13:42 UTC 2023


Hi,

>> What is the purpose of the primitive 196 Context>>#terminateTo:?

> Strongly related to prim 195 & 197. You have to check each context up the chain to see what exceptions might be dealt with & by which context.

My understanding is prim 195 (#findNextUnwindContextUpTo:) searches for unwind contexts and prim 197 (#findNextHandlerContextStarting) searches for handler context. But prim 195 (#terminateTo:) is unclear to me. #terminateTo comment says:

"Terminate all the Contexts between me and previousContext, if previousContext is on my Context stack. Make previousContext my sender."

Which doesn't say much except it's nilling all context's pc and sender between self and the argument. I wonder what else it does behind the scenes and why :)

In a paper from 2009 Eliot wrote:
"[...] there’s a primitive terminateTo: that does something similar to the context nilling in non-local return. It is a little simpler than non-local return (although not much) but it is just a variation on the same theme so I’ll spare you."

I wish Eliot didn't spare us :) Other than that I haven't found any further info.

Because the primitive 196 dates back to 2001 I'm unable to judge whether it's still essential to nil the intermediate contexts (to free stack pages or something).

In particular I'm trying to understand whether the use of #terminateTo *primitive* in #resumeEvaluating: and #resume:through: is essential or not.

Any additional info greatly appreciated.
Thanks,
Jaromir


--

Jaromír Matas

mail at jaromir.net


From: tim Rowledge<mailto:tim at rowledge.org>
Sent: Sunday, February 12, 2023 5:18
To: The general-purpose Squeak developers list<mailto:squeak-dev at lists.squeakfoundation.org>
Subject: Re: [squeak-dev] Questions about FullBlock closures



> On 2023-02-11, at 4:04 PM, Jaromir Matas <mail at jaromir.net> wrote:
>
> If I may, I have a question here: What is the purpose of the primitive 196 Context>>#terminateTo:? Why primitive and why terminating each context along the way? Naively, I'd think checking the two contexts are in the same sender chain and patching them via privSender should do but I'm sure I'm missing something here :)
>

Exception handling stuff. Strongly related to prim 195 & 197. You have to check each context up the chain to see what exceptions might be dealt with & by which context. Look at e.g. Process>>#terminate for some context.


tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
When flying inverted, remember that down is up and up is expensive



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230212/2eb878fb/attachment.html>


More information about the Squeak-dev mailing list