develooper Front page | perl.perl5.porters | Postings from April 2007

Re: Proposed changes and to regular expression interfaces in core

Thread Previous | Thread Next
April 10, 2007 10:34
Re: Proposed changes and to regular expression interfaces in core
Message ID:
Hash: SHA1

Moin Ævar,

On Tuesday 10 April 2007 04:14:19 Ævar Arnfjörð Bjarmason wrote:
> This incomplete patch shows the direction I'm going with this.
> I added two new callbacks for numbered capture vars and gave the
> existing one a new name. Now there's store/fetch/length for $1 where
> store croaks if assigned to. This means that one can write engines
> where C<$1 = "one"> works as expected (depending on what you expect of
> course). The logic in Perl_magic_len() was moved to a `length'
> callaback that can be overridden.
> I've also added callbacks to allow the regexp engine itself to
> implement a tie interface for %+ and %-. These aren't working at the
> moment but when they are the code that's currently in
> and universal.c will be part of the regex engine.
> I'm going to polish the interface a little, like putting all the
> named/numbered callacks in their own struct and make that a member of
> the regexp_engine struct. That way other engines can just drop in a
> macro to use the default behavior. The protototypes on the callbacks
> also need some going over, and I have to look better at magic hashes
> so that I can get %+ and %- to work properly like $1 et al.
> But once this is all done there should be a pretty sane regex api in
> core that re::engine::Plugin and others can target. Comments?:)

I can't comment much on this (I bet in a few years we know better :), 
however I would like to ask you to consider not to use too-strict 

For instance, exp() expects *exactly* one argument, so even when you 
overload exp(), you cannot do:


which is a limitation in the interface. Not sure if this applies to your 
work, but please consider that a future use might use more parameters :)

all the best,


PS: good work!

- -- 
 Signed on Tue Apr 10 19:24:58 2007 with key 0x93B84C15.
 View my photo gallery:
 PGP key on or per email.

 "You know the world is going crazy when the best rapper is a white guy,
 the best golfer is a black guy, the tallest guy in the NBA is Chinese,
 the Swiss hold the America's Cup, France is accusing the U.S. of
 arrogance, Germany doesn't want to go to war, and the three most
 powerful men in America are named 'Bush', 'Dick', and 'Colon'. Need I
 say more?"

  -- Chris Rock
Version: GnuPG v1.4.2 (GNU/Linux)


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