Not really. Either there's no error when you request the file be opened, and the block works, or you don't, and there's nothing to close. So as long as the block meant to open a file really does nothing else but try to open a file, there's nothing wrong with the scope of the ensure guard.
Ok you mean that if the opening fails by its exact failure we do not have to close? -- ok I did not think about failures as equals to do not create an handle that we should close :) tx to open my eyes on the obvious
If you want to be able to use the detectFile:do: to write code like: detectFile: [|fileStream| fileStream := FileStream newFileNamed: 'test.txt'. fileStream encoder: ISO88592TextConverter new. fileStream] do: [:aStream doStuff] the expanded guard would possibly be needed, to me that's giving aBlock too much responsibility though, I'd rather it'd be forced written: FileStream detectFile: [FileStream newFileNamed: 'test.txt'] do: [:aStream encoder: ISO88592TextConverter new; doStuff]
Cheers, Henry
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project