On Thu, Aug 17, 2006 at 11:45:06PM -0400, Joe Gottman wrote: > > -----Original Message----- > > From: Luke Palmer [mailto:[EMAIL PROTECTED] > > Sent: Thursday, August 17, 2006 8:44 PM > > To: Perl6 Language List > > > > Wasn't NEXT supposed to do something tricky, such as being mutually > > exclusive with LAST? I remember a debate some time ago where some > > complained "but that would be hard to implement", and the solution > > being mostly correct but failing in this case. > > > > I seem to recall NEXT being created in order to do things like this: > > > > for @objs { > > .print; > > NEXT { print ", " } > > LAST { print "\n" } > > } > > > > We also might consider using perl6's hypothetical features to > > implement NEXT correctly in all cases (except for those cases where > > the loop update condition cannot be hypotheticalized). > > > > Is this even possible? This would require Perl to know which iteration is > going to be the last one. In many cases there is no way to know this: > > repeat { > $num = rand; > print $num; > NEXT {print ',';} > LAST {print "\n";} > } while $num < 0.9; > > If rand is a true random-number generator it would take a time machine to > determine whether to call NEXT or LAST. > (Sorry for the double post.)
Depends on when it fires I guess. Your example might be equivalent to this perl5ish: while (1) { $num = rand; print $num; last if $num < 0.9; print ","; # NEXT } print "\n"; # LAST -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]