[squeak-dev] Re: Implementing control operators

Andreas Raab andreas.raab at gmx.de
Thu Apr 14 12:19:33 UTC 2011


On 4/14/2011 12:43, Bert Freudenberg wrote:
>
> On 14.04.2011, at 05:20, Ralph Johnson wrote:
>
>> On Wed, Apr 13, 2011 at 5:42 PM, Frank Shearar
>> <frank.shearar at angband.za.org>  wrote:
>>
>>> But I suppose I'm really asking this: is it _necessary_ to use primitive
>>> 199, or could one in _principle_ implement exception handling solely by
>>> in-image stack manipulation?
>>
>> Yes, you can implement exception handling by normal Smalltalk code,
>> without any special primitives.   Primitives make it go faster, and
>> they are necessary to trap blocks that leave your exception handler,
>> but the first dozen exception handling packages in Smalltalk (and
>> before the ANSI standard there are a lot of incompatible exception
>> handling systems for Smalltalk) all did it without primitives.
>>
>> -Ralph Johnson
>
> Squeak's exception-related primitives are purely an optimization:
>
> SystemNavigation default browseAllSelect: [:ea | ea primitive between: 195 and: 197]
>
> I just removed those three primitive invocations, and the system seemed to still work fine. Prims 198 and 199 are only used to mark methods, they don't actually do anything.
>
> Unless I am mistaken, the interpreter itself knows nothing about exceptions.

The VM knows not to return non-locally through ensure:/ifCurtailed: 
blocks (i.e., methods marked with primitive 198). But strictly speaking 
this isn't exception but rather unwind behavior.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list