Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Constant names come into conflict with Perl style?

by grinder (Bishop)
on Feb 08, 2007 at 09:25 UTC ( [id://598957]=note: print w/replies, xml ) Need Help??


in reply to Re: Constant names come into conflict with Perl style?
in thread Constant names come into conflict with Perl style?

All caps subs are reserved

Unfortunately, at some point last year the Perl 5 Porters accidentally broke this rule. There was a problem with cloning in threaded environments, and a magic subroutine named CLONE_SKIP was ushered in to deal with it.

Despite all the eyes of the people who worked on it, it escaped into the wild and it wasn't until a couple of months later that someone noticed that the name violated the guidelines (in that it really should have been called CLONESKIP).

Such is life.

• another intruder with the mooring in the heart of the Perl

  • Comment on Re^2: Constant names come into conflict with Perl style?

Replies are listed 'Best First'.
Re^3: Constant names come into conflict with Perl style?
by sgt (Deacon) on Feb 09, 2007 at 13:37 UTC

    Thanks for pointing this out. I actually remember the discussion on p5p and it was interesting, see the CLONE_SKIP story.

    So the underscore is not so good actually :(. The next best thing could be a simple "postfix".

    use constant MYPACKAGE_c => 'Universe::Tiny'; use constant RWXu => 0700; use constant MYLOGGERc => \do{local *FH; *FH};

    Actually a postfix like "c" or "_c" (or even "const" if you don't feel lazy) is good *visually* to remember they are gotchas like remembering when {}ing is actually necessary! (stressed by PBP)

  • MYPACKAGE_c->factory();
  • print {LOGGERc} "important login data";
  • #!/usr/bin/perl use strict; use warnings; use constant LOGGERc => \do{local *FH; *FH}; # silence warnings open LOGGERc, ">mylog" or die; # gotcha print {LOGGERc} "info...", "\n" or die; print {\*STDOUT} qx(cat mylog);
    decent_shell% perl -MLWP::UserAgent -Mconstant=PKGc,LWP::UserAgent -e +'print +PKGc->new();'
    cheers --stephan

Log In?
Username:
Password:

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

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

    No recent polls found