Close($file) required in Perl 6, unlike Perl 5

Patrick R. Michaud pmichaud at pobox.com
Sun Jul 17 15:00:30 UTC 2011


On Sun, Jul 17, 2011 at 10:21:19AM +0200, Moritz Lenz wrote:
> 
> Question to the Parrot developers: How could I implement DESTROY methods
> in Rakudo? Is there any vtable I can override, or so? Note that such a
> method might itself allocate new GCables. While not urgent, it's
> important for us in the long run.

A possibly related (and more relevant) question for Parrot devs:
is there any reason that FileHandle PMCs do not automatically 
flush + close on destruction?

    pmichaud at kiwi:~/nom$ cat fh.pir
    .sub 'main' :main
        $P0 = new ['FileHandle']
        $P1 = $P0.'open'('test.txt', 'w')
        $P1.'print'("Hello\n")
    .end
    
    pmichaud at kiwi:~/nom$ install/bin/parrot fh.pir
    pmichaud at kiwi:~/nom$ cat test.txt
    pmichaud at kiwi:~/nom$ ls -l test.txt
    -rw-r--r-- 1 pmichaud pmichaud 0 2011-07-17 09:57 test.txt

Pm


More information about the parrot-dev mailing list