Andreas Raab andreas.raab at
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: '') 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

  - Andreas

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

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

More information about the Squeak-dev mailing list