in reply to Re^3: yet another thread question: is Symbol::gensym threadsafe?
in thread yet another thread question: is Symbol::gensym threadsafe?

simply a part of history from before local was available

No. local predates modules and so also predates the Symbol module.

The generated name can be output when the file handle is dumped and it is nice to be able to distinguish between two file handles in such debug output. Hence unique names are generated.

You also appear to have disproven your own argument that the numbers overlapping between threads might cause a problem, especially since your proposed solution to that problem is to eliminate the numbers. :)

- tye        

  • Comment on Re^4: yet another thread question: is Symbol::gensym threadsafe? (history)

Replies are listed 'Best First'.
Re^5: yet another thread question: is Symbol::gensym threadsafe? (history)
by BrowserUk (Patriarch) on Oct 24, 2007 at 16:32 UTC
    The generated name can be output when the file handle is dumped ...

    So, even though the name is deleted from the symbol table, it can still be recovered from somewhere?

    And if it can be recovered from somewhere, then there is the possibility of conflict. Either in where the names are being stored for recovery. Or even in that someone, somewhere may be using those recovered names, assuming them to be unique.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      So, even though the name is deleted from the symbol table, it can still be recovered from somewhere?

      Yes.

      >perl -le "my $g = \do{ local *GLORB; *GLORB }; print $g; print *$g" GLOB(0x225f08) *main::GLORB

      But that's not a problem, or at least not a new one, because the globs created by auto-vivification of lexicals are not uniquely named either. Your hypothicical "someone" doesn't support lexical file handles, so I wouldn't worry about his inability to support threading.