On Thu, Dec 09, 2004 at 11:18:34AM -0800, Larry Wall wrote: > On Wed, Dec 08, 2004 at 08:24:20PM -0800, Ashley Winters wrote: > : I'm still going to prefer using :=, simply as a good programming > : practice. My mind sees a big difference between building a parse-tree > : object and just grepping for some word I want in a string. Within a > : rule{} block, there is no place except the rule object to keep your > : data (hypothetically -- haha), so it makes sense to have everything > : capture unless otherwise specified. There's no such limitation in a > : regular code block, so I don't see the need. > > Since regex results are lexically scoped in Perl 6, in a regular > code block we can do static analysis and determine whether there's > any possibility that $<foo> is referenced at all, and optimize it > away in many cases, if it turns out to be high overhead. But as Patrick > points out, so far capture seems pretty cheap.
It might turn out to be worth optimizing only when ALL of the "capture" blocks are unused - the saving from avoiding setup costs together with avoiding the (too small to be a bother by themselves) incremental costs, might be significantwhen taken together. --