On Wed, 23 Nov 2005, Ruud H.G. van Tol wrote:

 for ^5 { say }  # 0, 1, 2, 3, 4

The 'for' can go if a list (and also an array) would imply looping, when
it is positioned next to a block:

a.   say (0..4);
b.   { say; say } (0..4);

I'm not really sure: while I like it for its conciseness -and in particular I've often desired a very short, but clear, way to say: "do this #n times"- IIUC (Perl6 new rules for blocks/closures and dereferencing) this is only one dot or even whitespace away from passing a list into an anonymous sub. Which may be confusing after all...

The problem (if any!) does not persist for the postponed block form. But as far as code like

^5 { do_it };

is concerned, it is even _too_ concise, and I'd prefer some additional syntactical indication about what's going on. For my tastes,

^5: { do_it };  # But then also 5: { do_it }; [*]

would be perfect, were not the colon already taken for a bazillion other uses...

OTOH if I remember correctly there should be (provision for) a C<xx> variant that takes a closure and executes it over and over again.


[*] Or 5 -> { do_it }; but I strongly suspect this would interfere with pointy subs.


Michele
--
I am a deeply religious nonbeliever.
This is a somewhat new kind of religion.
- Albert Einstein

Reply via email to