On Wed, Dec 08, 2004 at 11:50:51AM -0700, Luke Palmer wrote:
: > Now suppose that we extend that "I am a boolean" feeling to
: >
: > <?{ code }>
: >
: > which might take the place of the confusing <(...)>, and make consistent
: > the notion that we always use {...} to invoke "real" code.
:
: Hmm... I'm just so attached to <(...)>. I find it quite beautiful. It
: also somehow communicates the feeling "you shouldn't be putting
: side-effects here".
Well, there is that. On the other hand, <{...}> is usually just as
side-effect free. I'm still of two minds about <?{...}> vs <(...)>.
Course, if we used �...� to interpolate something then �{...}�
might interpolate a rule, which would free up <{...}> for the code
assertion. Doesn't have your side-effectlessness feeling, but it is
at least symmetrical.
: > I think I'm leaning toward the idea that anything in angles that
: > begins alpha is a capture to just the alpha part, so the ? prefix is
: > merely a no-op that happens to make the assertion not start with an
: > alpha. Interestingly, that gives these implicit bindings:
: >
: > <after ...> $<after> $`
: > <before ...> $<before> $'
:
: I don't quite follow. Wouldn't that mean that these guys would get
: clobbered if you used lookaheads or lookbehinds in your rules?
The point is that you don't get the $`/$' equivalents unless you
explicitly put a lookbehind/lookahead assertion in your pattern:
/<after .*> foo <before .*>/
That has the benefit of telling the rule engine when it has to worry
about saving the prefix/postfix. Not knowing that is part of why
we had the sawampersand problem in Perl 5.
My other point is that the Perl 6 names of $` and $' fall out naturally
if we name the assertions appropriately. Unfortunately, $<after> and
$<before> don't work as well for variable names as they do for assertion
names. Maybe we just have <pre> and <post> forms that really mean <after .*>
and <before .*>.
: > Or we could use some standard delim for that:
: >
: > <ws-1> <ws-2> <ws-3>
: >
: > which is vaguely reminiscent of our "version" syntax. Indeed, if we
: > had quantifications, you might well want to have wildcards <ws-*> and
: > let the name be filled in rather than autogenerating a list. But
: > maybe we just stick with lists in that case.
:
: I can imagine this being a lot cleaner if the thing after the dash can
: be any sort of identifier:
:
: <ws-indent> if <?ws> <condition> <ws-comment>
Funny thing, I just wrote that into S05.pod.
: On the other hand, it could be misleading, since the standard naming of
: BNF uses dashes instead of underscored. I don't think it should be a
: big problem though.
Me either, since it's difficult to define a rule with a hyphen in the name.
And other delimiter candidates run into various problems too.
Larry