Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Catching errors in closing lexical filehandles

by eyepopslikeamosquito (Archbishop)
on Sep 27, 2004 at 09:06 UTC ( [id://394102]=note: print w/replies, xml ) Need Help??


in reply to Catching errors in closing lexical filehandles

Planning ahead for Perl 6, and after reading this thread, it seems best to get used to calling close() explicitly. AFAICT, in Perl 6, by default, the file handle will not get closed until a Dead Object Detection (DOD) run is triggered, which is not guaranteed to happen on scope exit.

This is because Parrot will replace Perl 5's simple reference counting with full garbage collection. Though languages (such as Perl 5) that run on Parrot can implement traditional Perl 5-style reference counting/timely destruction semantics, it seems likely that doing so will incur a performance penalty (triggering a DOD run on scope exit, for instance).

  • Comment on Re: Catching errors in closing lexical filehandles

Replies are listed 'Best First'.
Re^2: Catching errors in closing lexical filehandles
by gaal (Parson) on Sep 27, 2004 at 09:36 UTC
    Good stuff, thanks for the link.

    I for one wish Perl6 will have some way of requesting timely destroyed objects. :)

      Would it be enough that all items who wish to be notified of the destruction are notified in a timely fashion? This would be vs. at the time of the actual freeing of the memory, which the DOD run is needed for.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      I shouldn't have to say this, but any code, unless otherwise stated, is untested

        I think so! Not speaking as an expert here, but as a programming language user: once a variable goes out of scope, it is effectively out of the game. If going out of scope frees memory, wonderful. If it does other useful things like close files as well, wonderfuller. And if it does this at the best likely time, wonderfullest :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://394102]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found