Jonathan Scott Duff wrote:
- for minimal matching the ? is too far away from the operator that it
  applies to. It looks like it's doing something to the closure (and
  maybe it is) Should that be [foo]**?{$m..$n} instead?

- Bringing a closure into the picture seems to put too much power in
  such a simple construct.  [foo]**{ destroy_the_world; 0... }

This gave me 2 ideas. First:

  # not a closue, no runtime side effect, a straight compile
  /[foo]**(3..5)/

  # The closure is explicit and before the code it affects.
  # (Yay end-weight!)
  / {($min, $max) = binNsmall()} [foo]**($min..$max) /

Second, if it is a problem that '?' is too far away, how about this?

  [foo]**{5..3} # greedy
  [foo]**{3..5} # lazy

Kindof implies

  [foo]*  <==> [foo]**{*..0} # greedy
  [foo]*? <==> [foo]**{0..*} # lazy

but those would probably really be

  [foo]**{Inf..0} # greedy
  [foo]**{0..Inf} # lazy

But the greedy case would require careful processing, forget it. Might work if the closure idea were replaced with a semi-special non-closure syntax. Of couse we have the simpler syntax for those common cases anyhow, forget it. No, really.

Oh, is there a way to trick this closure syntax into being the '0 or more' equivalent? Suppose it would have to be returning an infinite list. That seems familiar, but I forget why.

I guess I'm not seeing the point in having a special closure based syntax. (Well, aside from Larry saying so. That ain't a bad reason. I'm just sayin'...) It could be abused in ugly ways and the only power it provides in the intended case is an arbitrary finite range. Seem this could be made to work with plain closures and simple range that allows variables as well as literals. It would be just as possible and not much less friendly.

Ok, so I guess I'd suggest

   / {($x,$y)=daRange()} <thing>**($x..$y) /

since parens kind of get you a list, which is really all you want to allow anyhow. It kinda looks a little like a code assertion too, well if you want to see it that way.

  / {($x,$y)=daRange()} <<thing>>* <($x..$y ~~ +@<<thing>>)> /

So maybe:

  / {($x,$y)=daRange()} <thing>**<($x..$y)> /

or

  / <thing>**<(deRange())> /

I wouldn't beat a drum for any of them though. Well, not more than I have. Those last two would be easy to mis-read. And actually, now that I think of it, setting the range in a closure has the requirements of running at canonical times. That's probably not what we want is it. I guess we're back to the closure syntax again. And the curly braces of the closure already have history attached to them. Forget it. No, I mean it this time. Honest.

Dan



Reply via email to