develooper Front page | perl.perl5.porters | Postings from February 2006

Do proxy constants break detection of the existance of constants?

Thread Next
From:
Adam Kennedy
Date:
February 23, 2006 02:09
Subject:
Do proxy constants break detection of the existance of constants?
Message ID:
20060223100929.30698.qmail@lists.develooper.com
For background, see...

http://rt.cpan.org/Ticket/Display.html?id=17639

The code at issue here is one that detects functions (and thus 
constants) that need hooks. Please don't ask why this code exists, as I 
don't have good answers yet, I don't fully understand the 
Module::Install loading mechanism :)

     my %seen;
     foreach my $obj ( @exts ) {
         while (my ($method, $glob) = each %{ref($obj) . '::'}) {
             next unless defined *{$glob}{CODE};
             next if $method =~ /^_/;
             next if $method eq uc($method);
             $seen{$method}++;
         }
     }

So it is detecting the existing of a function or constant using defined 
*{$glob}{CODE};

I'm assuming that Module::Install isn't the only place this is used, and 
that other places in all the existing Perl code out there do defined 
*{...}{CODE}.

Just in my own repositories I found about a dozen uses of defined 
*SOMETHING{CODE} although in my case it looks like non refered to constants.

So it would appear that any existing code that does definde *...{CODE} 
is going to return differently, depending on whether or not the constant 
has been used yet.

Adam K




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