On Tue, Dec 07, 2004 at 12:11:18PM -0700, Patrick R. Michaud wrote:
: I'm reviewing the updated S05 (2 Dec 2004) and ran across this
: in the "Hypothetical Variables" section:
: 
:     # Pairs of repeated captures can be bound to hashes:
: 
:         / %<options> := [ (<ident>) = (\N+) ]* /
: 
: Actually, I see three captures there, so should this instead read...?
: 
:         / %<options> := [ («ident») = (\N+) ]* /

Probably--that was the intent.  Or maybe that style of capture
ignores rule captures.  (If we do allow rule captures, we have to
worry about setting up a hash that is indexed by object rather than
by string, which seems not terribly useful for grammar reductions.)
Or maybe if there are more than two captures in the brackets, the
first becomes the key and the rest of them become a list value, in
which case <ident>'s $/ could be the first element and \N+ the second.

But somehow I expect that when someone writes (<foo>) they probably
usually meant («foo»).  On the other hand, it's an interesting idiom
if you really mean that you want the key to be the text value of the
match, and the value to be the object value of the match.

: Or is it that hypotheticals only bind to things captured by parens?
: If so, it might need clarification (or perhaps I'm overlooking the part
: that makes it clear).

No, I think you just found a blind spot in the design.

: A similar question arises a bit later, with
: 
:     And this puts a list of lists:
: 
:         / $<bar> := [ (<ident>) = (\N+) ]* /
: 
: Is the <ident> capture part of the list of lists that goes into $<bar>?

Wasn't intended to be.  I think I just missed changing it to «ident» in
the GBS.

Larry

Reply via email to