On Sun, Jul 17, 2011 at 11:00 AM, Patrick R. Michaud <pmich...@pobox.com> wrote: > 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?
The destructor does exactly that, but is not triggered by global teardown. > pmichaud@kiwi:~/nom$ cat fh.pir > .sub 'main' :main > $P0 = new ['FileHandle'] > $P1 = $P0.'open'('test.txt', 'w') > $P1.'print'("Hello\n") > .end > > pmichaud@kiwi:~/nom$ install/bin/parrot fh.pir > pmichaud@kiwi:~/nom$ cat test.txt > pmichaud@kiwi:~/nom$ ls -l test.txt > -rw-r--r-- 1 pmichaud pmichaud 0 2011-07-17 09:57 test.txt .sub 'main' :main $P0 = new ['FileHandle'] $P0.'open'('test.txt', 'w') $P0.'print'("Hello\n") $P0 = null sweep 1 .end > Pm > _______________________________________________ > http://lists.parrot.org/mailman/listinfo/parrot-dev >