develooper Front page | perl.perl5.porters | Postings from May 2008

Should potentially confusing labels emit a warning?

Thread Next
Aristotle Pagaltzis
May 8, 2008 04:35
Should potentially confusing labels emit a warning?
Message ID:
Hi all,

Andy Lester just wrote about this:

* <>
> Credit Randy Lauen for bringing this to my attention.  Today at
> my day job he found a horrifying code construct, one that I'd
> been using (incorrectly) for quite some time now.  You see,
> these two blocks are not the same:
>     BEGIN {
>         # Here's some code that gets executed at compile time
>     }
>     BEGIN: {
>         # This code gets executed at run time, because the colon
>         # after BEGIN means it's just a plain old label
>     }
> Randy had been tracking down a bug for over an hour and
> couldn't figure out why his variables weren't getting set at
> compile time.

A Perl::Critic policy has been submitted for this, but it seems
to me that this is a potential bug worthy of attention from the
core. Now, I am hesitant on adding new warnings but I think in
this case it really is worthwhile; it could, after all, be
disabled easily enough. (What was the consensus on making
`use warnings` mean something other than `use warnings 'all'`?)

Aristotle Pagaltzis // <>

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About