|
Boost : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2005-09-16 00:59:05
On 9/15/05 1:10 PM, "Eric Niebler" <eric_at_[hidden]> wrote:
> Answering an old question that got lost in the fray ...
>
> Scott Woods wrote:
>>
>> "What[ 0 ]" is the odd one out; it does not have an implicit mapping to a
>> manifest sub-expression. To RE-philes (I think my first exposure to $0 was in
>> "vi"?) it's de rigueur. To those C++ developers that were born more recently
>> but are familiar with STL, it's a wrinkle. Does processing of "what" always
>> involve "++what.begin()" only because "what.complete()" fails to compete with
>> tradition.
>
> I understand what you're saying, but I don't agree that it's that for solely
> for legacy reasons. In practice, the only reason why you might iterator over
> all sub-matches is to print them out. Otherwise, the sub-matches are accessed
> randomly, because (for example) the 1st sub-match is a date and the 3rd
> sub-match is an email address, and I'm not interested in the 2nd. See?
Didn't the serialization library run into a similar snag to this? That a
lot of people were asking about how to do a particular task, because the
author was the only one who never considered that task, so he never made the
interface provide that task easily. Similarly, we may run into a situation
where people commonly do non-random iterations through your "what" list.
It looks like the current setup is not STL-friendly. Most of the "what"
list is one type of thing, the in-order pieces of the regex parse. The
first item of the list doesn't match that pattern (since it's the whole
parse). I'm guessing that this "old" way wasn't a problem because people
expected 1-based arrays, so the 0-index could be special. That doesn't work
in a 0-based array culture, like C++ (or C). C++ people would expect the
0-index element to match the general rule of the list. This mixing of
element types mixes concerns (violating "keep it simple, silly"). A
STL-friendly alternative would to have separate member functions for the
whole-parse and the list-of-parse-pieces, then have a special function
(member or non-member) that generates a regex-culture combined list.
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk