Hi all,<br>
<br>
would you mind if I merged these changes (#haltOnceIf:)? As they have worked well for me so far, I will merge them next week if no one objects. See also KernelTests-ct.374. :-)<br>
<br>
Best,<br>
Christoph<br>
<br>
<font color="#808080">---<br>
</font><font color="#808080"><i>Sent from </i></font><font color="#808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><font color="#808080">Squeak Inbox Talk</font></u></a></i></font><br>
<br>
On 2020-01-09T14:42:46+00:00, commits@source.squeak.org wrote:<br>
<br>
> A new version of Kernel was added to project The Inbox:<br>
> http://source.squeak.org/inbox/Kernel-ct.1294.mcz<br>
> <br>
> ==================== Summary ====================<br>
> <br>
> Name: Kernel-ct.1294<br>
> Author: ct<br>
> Time: 9 January 2020, 3:42:36.672555 pm<br>
> UUID: 7409dcc3-160e-9d44-9712-f266e0f25973<br>
> Ancestors: Kernel-nice.1292<br>
> <br>
> Proposal: Add #haltOnceIf: to Object, which combines the strengths of #haltOnce and #haltIf:. Especially useful in performance-critical situations: It HaltOnce is disabled, the condition will not be evaluated at all.<br>
> <br>
> =============== Diff against Kernel-nice.1292 ===============<br>
> <br>
> Item was changed:<br>
>   ----- Method: Object>>haltIf: (in category 'debugging') -----<br>
> + haltIf: aCondition<br>
> +     "This is the typical message to use for inserting breakpoints during debugging. Param can be a block or expression, halt if true.<br>
> - haltIf: condition<br>
> -     "This is the typical message to use for inserting breakpoints during <br>
> -     debugging.  Param can be a block or expression, halt if true.<br>
>       If the Block has one arg, the receiver is bound to that.<br>
> +      If the condition is a selector, we look up in the callchain. Halt if any method's selector equals selector."<br>
> -      If the condition is a selector, we look up in the callchain. Halt if<br>
> -       any method's selector equals selector."<br>
> -     | cntxt |<br>
>   <br>
> +     ^ (self meetsHaltCondition: aCondition)<br>
> +         ifTrue: [self halt]!<br>
> -     condition isSymbol ifTrue:[<br>
> -         "only halt if a method with selector symbol is in callchain"<br>
> -         cntxt := thisContext.<br>
> -         [cntxt sender isNil] whileFalse: [<br>
> -             cntxt := cntxt sender. <br>
> -             (cntxt selector = condition) ifTrue: [Halt signal].<br>
> -             ].<br>
> -         ^self.<br>
> -     ].<br>
> -     (condition isBlock <br>
> -             ifTrue: [condition cull: self] <br>
> -             ifFalse: [condition] <br>
> -     ) ifTrue: [<br>
> -         Halt signal<br>
> -     ].!<br>
> <br>
> Item was added:<br>
> + ----- Method: Object>>haltOnceIf: (in category 'debugging') -----<br>
> + haltOnceIf: aCondition<br>
> +     "Check aCondition and halt, unless we have already done it once. See #meetsHaltCondition:."<br>
> +     <br>
> +     self haltOnceEnabled ifFalse: [^ self].<br>
> +     ^ (self meetsHaltCondition: aCondition)<br>
> +         ifTrue: [<br>
> +             self clearHaltOnce; halt].!<br>
> <br>
> Item was added:<br>
> + ----- Method: Object>>meetsHaltCondition: (in category 'debugging') -----<br>
> + meetsHaltCondition: aCondition<br>
> +     "If the Block has one arg, the receiver is bound to that.<br>
> +      If the condition is a selector, we look up in the callchain. Halt if any method's selector equals selector."<br>
> +     <br>
> +     aCondition isSymbol ifTrue: [ | ctxt |<br>
> +         "only halt if a method with selector symbol is in callchain"<br>
> +         ctxt := thisContext.<br>
> +         [(ctxt := ctxt sender) isNil] whileFalse: [<br>
> +             (ctxt selector = aCondition) ifTrue: [^ true] ].<br>
> +         ^ false ].<br>
> +     ^ aCondition isBlock <br>
> +             ifTrue: [aCondition cull: self] <br>
> +             ifFalse: [aCondition value]!<br>
> <br>