Constant vs. Readonly

Jobindex hosted the latest Copenhagen Perl Mongers meeting. The topic was Perl::Critic. Henrik Hald Nørgaard from Jobindex gave a nice general presentation on Perl::Critic. During and after there was a lot of discussion on various aspects of Perl::Critic, testing and Perl in general.

Jobindex was also disabling the Perl::Critic::Policy::ValuesAndExpressions::ProhibitConstantPragma policy, which is something I always do so after the meeting I sat down and made a write-up of why that is – something I have been meaning to do for a long time.

The problem with the policy is that is recommends using Readonly instead of constants. Readonly variables are nice, but they cannot be used for optimization by the Perl interpreter like constants can, if you for example implement a DEBUG constant.

In addition to the write-up I examined my long TODO list and implemented one of the Perl::Critic policies I have been meaning to implement also for a long time:

Perl::Critic::Policy::Modules::ProhibitUseLib

I will write more on this policy later and another one, which popped to mind when implementing the first.

Perl::Critic::Policy::Modules::RequireVersionFormat

Next meeting, the May meeting will be a lightning talk session on testing.

Advertisements
Constant vs. Readonly