> On 30.11.2014, at 11:18, Thierry Goubier <thierry.goub...@gmail.com> wrote:
> 
> Le 30/11/2014 11:06, Max Leske a écrit :
>> The code would look like this:
>> 
>> [ | file |
>>      file := StandardFileStream forceNewFileNamed: ‘foo’.
>>      file nextPutAll: ‘bar’ ]
>>              ensure: [ file close ].
>> 
>> Why that is considered bad practice however, I can’t tell.
> 
> This one would fail because file is a temp to the block (and not visible to 
> the ensure block).

If it weren’t visible, wouldn’t the compiler raise an exception?

> 
> Another problem is that, if you have a failure in forceNewFileNamed:, file is 
> nil and the ensure: fail as well.

True, but that’s a problem this rule doesn’t really cover I guess. That one’s 
up to the developer.

> 
> This is how I interpret that rule.
> 
> Thierry
> 
> 


Reply via email to