xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

After six days including weekend, I've read perlthrtut, threads and many nodes about threads in perlmonks (mainly by BrowserUk). So I'm ambitious to write a multi-threads program.

But before I start, I have two small tiny questions about threads: why name of threads hasn't capital letters, on the contrary to most of modules. And, if thread module is outdated, why not combine thread::whatever to threads?

just curiously, hope gurus give me answer. ;)

I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Replies are listed 'Best First'.
Re: name of threads
by BrowserUk (Patriarch) on Jul 04, 2007 at 16:25 UTC

    Best as I can figure it though I haven't seen it written anywhere, so if anyone knows better, I to would like to hear the real skinny?

    1. why name of threads hasn't capital letters, on the contrary to most of modules.

      The threads::shared module acts in a vaguely pragma-like fashion in as much as, if threads has not been loaded prior to threads::shared, then the facilities provided by the latter do not cause errors, but act as no-ops. Ie. They silently do nothing.

      The intention being (I think), that authors could write modules, that need to use my $var :shared;, share() and lock() etc. if they are running in a threaded program, but not, if they were not.

      By making threads::shared silently do nothing unless threads was loaded, it (theoretically), allowed the authors to avoid having to hard code explicit tests for threads into their modules.

      The naming of threads all lower case was necessary so that the name of threads::shared could also be all lower case.

      Whether the aim of creating transparently 'dual mode' modules is actually achievable I'm doubtful.

    2. if thread module is outdated, why not combine thread::whatever to threads?

      By "thread module", I assume you mean Thread. Basically because of history I think--nothing is ever deleted from CPAN so renaming things is a problem.

      I wish that there was some sensible action that could be taken to avoid the confusion between those Thread::* modules that work with threads and those that were written for use with Thread and either haven't or cannot be modified for use with the former.


    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.
Re: name of threads
by moritz (Cardinal) on Jul 04, 2007 at 15:06 UTC
    Regarding the case: most "pragmatic" modules (like strict, warnings, diagnostics) use lower case names, maybe threads was intented to be pragmatic as well.
      No offense to you, I don't think threads is a pragmatic because I have never seen any pragmatic attached '::'

      I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction