Re: parsing behavior of a subrule without/with a repetition specifier

[email protected] ((Randal L. Schwartz))
Newsgroups perl.recdescent
Organization Stonehenge Consulting Services; Portland, Oregon, USA
Message-ID <[email protected]>
>>>>> "Damian" == Damian Conway <[email protected]> writes:

Damian> I don't think C<x> is the right analogy for RecDescent repetition operators.
Damian> The behaviour of C<*> and C<+> in regexes is a closer model.

Damian> I guess it depends on your poitn of view. I would have said that the
Damian> absolute consistency with which *every* repetition (regardless of its
Damian> number) returns an array ref is better than the alternative:

Damian>         christmas:
Damian>                 gold_rings(5)                   # returns array ref
Damian>                 calling_birds(4)                # returns array ref
Damian>                 French_hens(3)                  # returns array ref
Damian>                 turtle_doves(2)                 # returns array ref
Damian>                 partridge_in_a_pear_tree(1)     # returns scalar value

Damian> Especially if you have to change the count at some later point, which 
Damian> would mess up any code relying on the type of value returned.

I prefer it the way it is.  (1) may say "match one", which is the
same as leaving it off, but (1) is closer to (2) than to "". :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.