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

Re: doco improvement for attributes.pm

Thread Previous | Thread Next
From:
David Cantrell
Date:
March 29, 2012 03:19
Subject:
Re: doco improvement for attributes.pm
Message ID:
20120329101851.GA14678@bytemark.barnyard.co.uk
On Wed, Mar 28, 2012 at 04:42:02PM -0400, Matthew Horsfall (alh) wrote:
> 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.

Updating to get rid of refaddr, yes.  As for how to deal with closures I
don't know what would be best.  The doco definitely needs this little
bit of explication for the simple non-closure case.

-- 
David Cantrell | London Perl Mongers Deputy Chief Heretic

   When a man is tired of London, he is tired of life
      -- Samuel Johnson

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