[Vm-dev] questions about a couple of primitives
eliot.miranda at gmail.com
Mon Aug 31 22:00:34 UTC 2020
On Mon, Aug 31, 2020 at 2:00 PM Florin Mateoc <florin.mateoc at gmail.com>
> I think this is especially confusing since the comment says that the
> primitive always fails, and then the expectation is that the Smalltalk code
> that follows is executed instead. But that code does not do what the method
> actually does
I disagree. It does exactly what the method does (it *is* the
implementation of the method) unless the stack is unwound. Yes, the
comment could point the reader to Context>>#resume:through: which runs the
ensure: & ifCurtailed: blocks on unwind. Bit otherwise ifCurtailed: is not
somehow magically not executed. It is what it is ;-)
As I said earlier, ifCurtailed: only evaluates its argument if a non-local
return or exception return is taken and the normal return path is not
taken. See Context>>#resume:through: which runs the ensure: & ifCurtailed:
Can I confirm that your dissatisfaction is with the comment? Or do you
really think the ifCurtailed: method does not execute verbatim in the
absence of unwinds? If the former, you're welcome to submit an improved
comment. If the latter, you're mistaken.
On Mon, Aug 31, 2020 at 4:51 PM Florin Mateoc <florin.mateoc at gmail.com>
>> Hi Eliot,
>> Sorry about top-posting previously. Stupid Gmail!
>> Eliot Miranda via <https://support.google.com/mail/answer/1311182?hl=en>
>> 4:40 PM (4 minutes ago)
>> to Open
>> On Mon, Aug 31, 2020 at 4:40 PM Eliot Miranda <eliot.miranda at gmail.com>
>>> Hi Florin,
>>> On Mon, Aug 31, 2020 at 1:35 PM Florin Mateoc <florin.mateoc at gmail.com>
>>>> Hi Eliot,
>>>> Thank you for your reply and for the extra details about #instVarAt:.
>>>> To answer your question, I would have expected the primitive to fail
>>>> for non-pointers objects, as I associate in my mind instvars with named
>>>> instvars, but I am not invested in this (mis)association, so thank you for
>>>> correcting it.
>>>> But regarding #ifCurtailed, I know that primitives198 1nd 199 are not
>>>> "real", I was referring to something else. The primitive failure code in
>>>> the method #ifCurtailed never touches the argument, regardless of the path
>>>> taken. I think that is incorrect, even if only for documentation purposes.
>>> I don't understand. I see no error code. We're talking about this
>>> method right?
>>> BlockClosure>>ifCurtailed: aBlock
>>> "Evaluate the receiver with an abnormal termination action.
>>> Evaluate aBlock only if execution is unwound during execution
>>> of the receiver. If execution of the receiver finishes normally do
>>> not evaluate aBlock. N.B. This method is *not* implemented as a
>>> primitive. Primitive 198 always fails. The VM uses prim 198 in a
>>> context's method as the mark for an ensure:/ifCurtailed: activation."
>>> | complete result |
>>> <primitive: 198>
>>> result := self valueNoContextSwitch.
>>> complete := true.
>> I did not mention an error code, I was talking about the "primitive
>> failure code", referring to the Smalltalk code that gets invoked when the
>> primitive fails (the three rows after the pragma).
>> This Smalltalk code does not touch the method's argument (aBlock), so it
>> looks as if aBlock is never evaluated
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev