In short, nearly every case where I'm looking to use a "raw" closure
can be handled almost as easily by prefacing it with C<do> (if the
block doesn't take parameters) or C<do given> (if it does).  A bit
more wordy than I'd like, but acceptable; it still reads well.
Although I'd recommend pointing this option out in S05, right after
you say that s[pat] = { doit() } won't work.

On 10/11/06, Larry Wall <[EMAIL PROTECTED]> wrote:
     s:s:g[<,> (\w+): (.+) <,>] = do for @().each -> $key, $val { $key => $val }

Minor point: Since the right side gets called for each left-side
match, isn't the C<.each> redundant?  For that matter, isn't the
C<for> overkill as well?  C<@()> will only ever have two elements per
call, after all...

: Could closures be
: an exception to the "implicit curlies" rule?  That is: if you supply
: your own closure on the right, the substitution algorithm accepts it
: as is; if you supply anything else, it gets wrapped in a closure as
: described.

Could do that too (and there's even precedent with attribute defaults),
but outlawing it (at least for now) keeps people from cargo culting
P5's s{foo}{bar} into P6's s{foo}={bar}.

This would be the "ye olde code doesn't do a text substitution
anymore" issue, right?  And there _is_ still the possibility of
permitting it in some later subversion of Perl 6, once people have
gotten Perl 5 out of their systems...

--
Jonathan "Dataweaver" Lang

Reply via email to