develooper Front page | perl.perl5.porters | Postings from December 2010

Re: [perl #78634] Conflict in defining constant INIT with INITblocks results in weird errors

Thread Previous
From:
Aristotle Pagaltzis
Date:
December 23, 2010 18:28
Subject:
Re: [perl #78634] Conflict in defining constant INIT with INITblocks results in weird errors
Message ID:
20101224022841.GC30597@klangraum.plasmasturm.org
* Zefram <zefram@fysh.org> [2010-11-16 23:00]:
> Father Chrysostomos via RT wrote:
> >> use constant INIT => 4;
>
> There's a problem with this line: INIT, as a subroutine name,
> is magic to Perl, and defining a constant in this way actually
> amounts to defining a subroutine.  If you change the name to
> XNIT then nothing funny happens.

It seems to me that `constant` should warn about this (as well
as all the other special names (`BEGIN`, `END`, `CHECK` etc.)).

For some reason I even feel it should maybe die… but since
const subs aren’t likely to have any side effects I can’t find
any reason to back up my gut feeling and it seems to fall under
“give them rope”.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About