Timothy Rowledge tim at
Tue Jan 27 01:30:57 UTC 2004

On Jan 26, 2004, at 1:38 AM, Andreas Raab wrote:

> That's why I'm saying putting the resource creation inside the ensured 
> block
> doesn't give you anything, and that's why you don't need explicit 
> guards nor
> stub methods in UndefinedObject. You simply can't handle failures that 
> arise
> from resource creation contained inside some ensured block that should 
> cover
> the release of that resource.
Not quite completely true, though it would require a change in the 
resource allocation behaviour to be clean.
a) one could simply do the ugly thing and make UndefinedObject respond 
to the resource release message (yuck)
b) one could return an instance of FailedResourceAllocationDoohickey 
rather than nil when the file open fails and provide it with protocol 
to do various useful things. Like maybe retry under some situations, 
release 'cleanly' and so on.

With b) we would anticipate an exception from the "do stuff" part of 
the ensured block which would then unwind and the 'file' would handle 
#close by doing nothing much. Is this a good pattern? Not sure right 


More information about the Squeak-dev mailing list