develooper Front page | perl.perl5.porters | Postings from March 2009

Re: Known issue or design decision? Constant sub redefinitionignores "no warnings 'redefine'"

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
March 26, 2009 07:15
Subject:
Re: Known issue or design decision? Constant sub redefinitionignores "no warnings 'redefine'"
Message ID:
20090326141511.GC11941@iabyn.com
On Thu, Mar 26, 2009 at 09:05:24AM +0100, Bram wrote:
> The subject of the patch ('mandatory warning') suggests that it is  
> intended that the warning can't be disabled. (Which agrees with perldiag 
> because of the lack of (W redefine))

If I were to hazard a guess, I'd say it's because const sub uses are
in-lined at compile-time; therefore changing the sub definition later is
likely to surprise the user:

    sub FOO() { 1 };
    *FOO = sub() {2};
    print FOO, FOO(), &FOO(), "\n";

which prints

    112

-- 
Never work with children, animals, or actors.

Thread Previous | Thread Next


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