On Thu, Jul 12, 2012 at 05:36:58PM +0300, Gabor Szabo wrote:
> The following script leaves and epty 'data.txt' behind.
> Only if I call $fh.close is the file contents saved.
> 
> Is this a feature?
> 
> use v6;
> 
> my $fh = open 'data.txt', :w;
> $fh.print("hello\n");

While Rakudo and Parrot _should_ be closing the file upon
program exit, it's still a good idea to close filehandles
explicitly.  Since the GC doesn't have reference countfing, 
it's not always the case that filehandles are automatically
closed as soon as the last reference is broken, thus you
really want to close the filehandle explicitly.

It might be good for Rakudo and/or Parrot to have an option
to issue a warning whenever a open filehandle is closed due to
garbage collection, though.

Pm

Reply via email to