List Info

Thread: Re: Callbacks for named captures (%+ and %-)




Re: Callbacks for named captures (%+ and %-)
user name
2007-05-31 08:37:35
On Wed, May 30, 2007 at 12:28:52AM +0000, Ævar Arnfjörð
Bjarmason wrote:
> On 5/27/07, demerphq <demerphqgmail.com> wrote:
> >I am wondering if there is some set of assumptions
that you and I are
> >making that are not explicit that are affecting how
we see this and
> >therefor resulting in us talking past each other.
> >
> >I think ive given a good description of how I see
things working but
> >if not then please let me know, conversely can you
give a structural
> >outline of how things would work? Im not sure if I
understand you
> >properly. At least it seems that way from our
discussion on it.
> 
> Sorry for the late reply, I'll try to reply to the rest
of the post later.
> 
> I opted for finishing the patch to demonstrate how I
saw this working,
> it forms some sort of point in this argument, whether
it's for or
> against what I've been saying I don't know.
> 
> I've also uploaded a new dev version of
re::engine::Plugin and
> re::engine::PCR to CPAN which use the new features.
Although they
> don't make the best demonstrations of its usage it's
better than
> nothing.
> 
> As for the patch I've removed re::regnames_iterinit
and
> re::regnames_iternext as discussed, kepth the old
NamedCapture.pm
> interface. re::regnames_count() is now implemented in
terms of the
> SCALAR callback with a RXf_HASH_COUNT flag.
> 
> I also added defines for the -2, -1 and 0 magic
integers and misc pod
> updates to perlreapi.pod. I could submit this as a
seperate patch but
> it crept into my working tree

Sorry for my late reply, and I'm going on vacation, so I
probably won't
have time to repsond, sorry.

This looks good to me. The re::regname* and %+, %- use the
same
functions, so they are just a different interface to the
same data.
There are a bit many callbacks, but it's clear what they do,
and you
normally don't have to override them all.

Some other things not really related to your patch:

Because we make the re::regnames normal functions to access
the buffers
(which I'm very happy about). I think they should move to a
different
namespace. The 're' pragma is used to "*alter* regular
expression behaviour".
Because the 're::regname*' are subs to access things they
don't belong there. 
I'm thinking about 'regex' namespace. Also I would like them
renamed,
I like 'named_buff', like what they are called internally.
So we get "regexp::named_buff"
(is_regexp should also move to the new namespace).

consistent naming: CALLREG_NAMEDBUF_DELETE rename to
CALLREG_NAMED_BUFF_DELETE (or CALLREG_NAMEDBUFF_DELETE)

I rember in previous attempts you made it possible to
override the tie, was
there something wrong with this method? Another method is
make a
callback for %+ and %- directly, so the regex engine can
return anything
it wants. But the default uses CALLREG_NAMED_BUFF_FETCH et.
al. but you
won't need the callback for CALLREG_NAMED_BUFF_DELETE et.
al. if you
want to override them you have to override %+ and %-
completely.

Because I consider the re::regnames the default interface, I
would like
a callback for that like CALLREG_NAMED_BUFF_LIST instead of
CALLREG_NAMED_BUFF_FIRST|NEXT.
And then the CALLREG_NAMED_BUFF_FIRST|NEXT implemented using
the *_LIST
callback. But I'm not sure that is possible.

-- 
Gerard Goossen
TTY Internet Solutions


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )