Re: parsing behavior of a subrule without/with a repetition specifier
[email protected] (Damian Conway)
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
Terrence suggested:
> I guess what Akio is saying (or what I get from what he is saying) is
> that, in pure Perl, a repetition count of 1 returns the same data
> structure as leaving off the repetition operator. However, P::RD is
> different and hence surprising/non-intuitive in this respect.
I don't think C<x> is the right analogy for RecDescent repetition operators.
The behaviour of C<*> and C<+> in regexes is a closer model.
I guess it depends on your poitn of view. I would have said that the
absolute consistency with which *every* repetition (regardless of its
number) returns an array ref is better than the alternative:
christmas:
gold_rings(5) # returns array ref
calling_birds(4) # returns array ref
French_hens(3) # returns array ref
turtle_doves(2) # returns array ref
partridge_in_a_pear_tree(1) # returns scalar value
Especially if you have to change the count at some later point, which
would mess up any code relying on the type of value returned.
Damian