> From: Bill Ward <[email protected]>

> This gives you quite friendly policy identifiers
>
>       [ValuesAndExpressions::ProhibitConstantPragma] Pragma "constant" used 
> at line 22, column 1. (Severity: 4)
>
> What's wrong with 'use constant'?

Well, nothing's "wrong" with it.  It does, however, get clumsy in some cases.  
For example:

  use constant FOO => 3;
  print $data->{+FOO}; 
  print "We have @{[FOO]} widgets";
  # or
  print "We have ".FOO." widgets";

Versus:

  use Readonly;
  Readonly my $FOO => 3;
  print $data->{$FOO}; 
  print "We have $FOO widgets";

Readonly constants are just easier to use and have fewer "gotchas".

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to