I tend to protect the asFilename/open inside the block as you describe
but I would guess it depends on what resources are allocated as to
whether you need the close.

I was additionally wondering about the pattern

^file
   ifNil: [ nil ]
   ifNotNil: [ ...]

if file is nil, then does it not answer self to ifNotNil: ?
^file ifNotNil: [...]

thanks

Mike

On Wed, Jul 16, 2008 at 9:33 AM, Stéphane Ducasse
<[EMAIL PROTECTED]> wrote:
> Hi norbert
>
>>> I have a question:
>>>        - would not be better to even wrap the on: into the first block of
>>> the ensure: message?
>>
>> What do you mean? Can you give an example?
>
> In VW I was used to write something like that from memory
>
>        [ f := 'foo.bar' asFilename.
>        f open....
>
>
>        ] ensure: [f close]
>
> so the file creation was protected.
>
>>
>>
>>>        - do we have to close a file even if its creation failed?
>>
>> Is there anything in the above examples that raises this question?
>> Usually it is the other way round. You can't close a file (that you
>> don't have) if the creation failed.
>>
>> I was wondering about the name of the methods. Is a idiom
>>
>> smthg create
>> aBlock value: smthg
>> smthg destroy
>>
>> not supposed to be called during: ?
>
> Yes but apparently in FileStream there are newfileNamed:do:....
> I guess that this is a ruby idiom imported by avi
>
> Stef
>>
>>
>> Norbert
>>
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [email protected]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to