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

Re: [perl #132760] Blead Breaks CPAN: YANICK/List-Lazy-0.3.0.tar.gz

Thread Previous | Thread Next
Dave Mitchell
February 20, 2018 21:10
Re: [perl #132760] Blead Breaks CPAN: YANICK/List-Lazy-0.3.0.tar.gz
Message ID:
On Tue, Feb 20, 2018 at 10:35:06AM -0800, Father Chrysostomos via RT wrote:
> Specifically, how does one signal from a MODIFY_CODE_ATTRIBUTES sub that
> the attribute is going to install parsing hooks of some sort?
> I think the answer is that the module needs to be able (even at the XS
> level) to enquire as to whether the sub’s op-parsing has begun yet.  Do
> we need a new API function for that?

My understanding of custom attributes is that they are all handled
*after* compilation of the sub is completed; i.e.

    sub f :Foo(foo) :Bar(bar) { ....}

is compiled as

    sub f  { ....}
    use attributes __PACKAGE__, \&f, 'Foo(foo)', 'Bar(bar)';

(with MODIFY_CODE_ATTRIBUTES() called by attributes->import()).

So it doesn't really matter whether the attribute appears before or after
the signature: these three:

    sub f ($a) :Foo(foo) :Bar(bar) { ....}
    sub f :Foo(foo) ($a) :Bar(bar) { ....}
    sub f :Foo(foo) :Bar(bar) ($a) { ....}

all compile to the equivalent of:

    sub f  ($a) { ....}
    use attributes __PACKAGE__, \&f, 'Foo(foo)', 'Bar(bar)';

and thus order is only important for builtin attributes.

(Or perhaps I'm misunderstanding something).

My get-up-and-go just got up and went.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About