Hi,

Nicholas Clark wrote:

Is there a list of the patches to blead, from which one can create a cumulative
patch representing the changes needed to add assertions.

There were not too many. Greeping for assertions on the Changes files seems to show them all: 18727, 18735, 18739, 18750, 18827, 18828, 19808.


Now that the assertion code is (I believe) fully feature complete, I'm
wondering if it can be refactored into a minimal set of core hooks, and an
XS module in ext. Having more hooks increases what is possible for future
authors to achieve as independent modules released to CPAN.

There were two mayor reasons why assertions could not be implemented outside the core:

1) assertion magic happens at compile time changing the way assertion calls are compiled inside their callers.

Extending perl to allow customizing how subroutine calls are compiled, well, that makes me thing about macros, but adding support for macros to perl5 seems a bit crazy to me :-)

...though some kind of low level macros able to work with OPs could be used, for instance:

  sub sqr : macro {
      return B::OPBIN->new("mul", $_[0], $_[0]->clone);
  }


2) subs and attributes:

currently, subs attributes are very poorly handled, there are very few things one can do with them, specially because there is no information about the GLOBs where the subs are going to be stored.

Attribute::Handlers tries to work around that, but it is far from perfect, mostly because it runs at INIT or CHECK time, and so too late for attributes that want to influence compile time!

I think this could be done better, maybe adding support for a new MODIFY_CODEGLOB_ATTRIBUTES hook. Or maybe two, one called before the sub is defined and another after (MODIFY_PRECODEGLOB_ATTRIBUTES, MODIFY_POSTCODEGLOB_ATTRIBUTES), but well, it's a complex matter and all the different possible cases should be considered.

Cheers,

  - Salvador.

Reply via email to