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

Re: doco improvement for attributes.pm

Thread Previous | Thread Next
From:
wolfsage
Date:
March 28, 2012 13:42
Subject:
Re: doco improvement for attributes.pm
Message ID:
CAJ0K8bh0NWLFBwJGThBnPAJgt12NDo-EwCeGeS7-ZHJhc=rR9Q@mail.gmail.com
On Wed, Feb 29, 2012 at 12:40 PM, David Cantrell <david@cantrell.org.uk> wrote:
> On Thu, Feb 16, 2012 at 05:06:51PM +0000, I wrote:
>
>> +It is up to this method to store the list of attributes if they will be
>> +needed later, as well as checking for any errors.  In this example there
>> +are no error conditions, so we just store:
>> +
>> +  my %attrs;
>> +  sub MODIFY_CODE_ATTRIBUTES {
>> +    my($package, $subref, @attrs) = @_;
>> +    $attrs{ refaddr $subref } = \@attrs;
>> +    return;
>> +  }
>
> Turns out that blindly looking at refaddr($subref) doesn't always Do The
> Right Thing.  This code gets called when the subroutine with attributes
> is being compiled, and if it's a closure you sometimes (maybe always?)
> get a different refaddr at this point than the subroutine ends up with
> after it's been compiled.  I have no idea off the top of my head how to
> fix this to take that into account.
>
> Also I seem to remember there being some Argument recently about whether
> refaddr() should be in core or not but forget what the final decision
> was.  In this case (modulo the closure stuff above) simply stringifying
> the subref does the job, so refaddr can be cut out.

Should the docs be updated again then? The original patch is still
applied and this last email seems to indicate it needs to be changed.

-- Matthew Horsfall (alh)

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