finalisation

Andreas Raab andreas.raab at gmx.de
Tue Jan 27 13:05:52 UTC 2004


> Does this not catch all the possibilities ?

No, of course not. That's why I find the style of putting the resource
creation inside the ensured block so terribly misleading. It puts you under
the impression that you caught all the possibilities, where it is easy to
see from an example like

    [file := (FileStream newFileNamed: 'foo.bar') halt.
    ] ensure:[file close].

that you do not catch anything that happens on the right hand side of the
assignment. IOW, execute the above and close the resulting debugger - it
will end up with a DNU for file close which illustrates that - although the
file has been created - it is not being cleaned up after encountering the
halt.

Cheers,
  - Andreas

----- Original Message ----- 
From: "Brent Pinkney" <brent.pinkney at aircom.co.za>
To: "The general-purpose Squeak developers list"
<squeak-dev at lists.squeakfoundation.org>
Sent: Tuesday, January 27, 2004 10:29 AM
Subject: Re: finalisation


> This is what I often do:
>
>   [file := FileStream newFileNamed: 'foo.bar'.
>      ] ensure:
> [ file ifNotNilDo: [ :x | x close ] ].
>
>
> Does this not catch all the possibilities ?
>
> Brent
>




More information about the Squeak-dev mailing list