Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Implicit closing of files

by ikegami (Patriarch)
on Jun 17, 2008 at 12:57 UTC ( [id://692500]=note: print w/replies, xml ) Need Help??


in reply to Re: Implicit closing of files
in thread Implicit closing of files

Are you saying the documentation is wrong? Quote close:

Closes the file or pipe associated with the file handle, flushes the IO buffers, and closes the system file descriptor.

Replies are listed 'Best First'.
Re^3: Implicit closing of files
by dragonchild (Archbishop) on Jun 17, 2008 at 13:00 UTC
    That would be correct for an explicit close(). If you let the variable fall off the end of a block, now you're depending on destruction. Destruction in Perl isn't timely.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

      Everything I've seen says that destruction in Perl is timely. Destruction occurs as soon as the value's ref count reaches zero. Do you have any documentation to contradict that?

      This is in contrast with Java, where garbage collection is not as predictable.

      Update: The only documentation bit I've found is in perlref:

      Hard references are smart--they keep track of reference counts for you, automatically freeing the thing referred to when its reference count goes to zero.

      And it goes on to say

      If that thing happens to be an object, the object is destructed.

      There's no mention of a delay or of it being deferred. Although it doesn't say explicitly say "immediately", I'm still convinced it is because my belief is based on much more than that one statement.

        Ah. I have found my misremembering. Calling of DESTROY is neither timely nor ordered. Destruction in Perl is timely for lexicals. But, I can't find anything about destruction of localized variables. I would figure that the recovery of the hidden value is timely. But, that doesn't imply that the destruction of the covering value is timely.

        I, of course, would love to hear from TimToady, chromatic, or some other guts person. And, frankly, being able to depend on timely destruction would be nice.


        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

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

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

    No recent polls found