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