It looks like Duff's Device <http://www.lysator.liu.se/c/duffs-device.html>
won't be possible in Perl6. This is a shame.

     sub duff ($from) {
         # real life would use reference here, this is a demo
         # dummy: simulate write to serial i/o port
         my $to;
         my $i = 0;
     
         my ($n, $count);
         $count = $from.chars;
     
         $n = ($count + 7) / 8; # use integer in effect
     
         %MY::«{"l" ~ $count % 8}».goto();
         l0: do {    $to ~= (substr $from, $i++, 1);
         l7:         $to ~= (substr $from, $i++, 1);
         l6:         $to ~= (substr $from, $i++, 1);
         l5:         $to ~= (substr $from, $i++, 1);
         l4:         $to ~= (substr $from, $i++, 1);
         l3:         $to ~= (substr $from, $i++, 1);
         l2:         $to ~= (substr $from, $i++, 1);
         l1:         $to ~= (substr $from, $i++, 1);
             } while (--$n>0);
     
         return $to;
     }

In Pugs at least, labels may only only be assigned to blocks. Any chance
the language gets to have them in more arbitrary places? Would this in
fact be enough to make this work?

-- 
Gaal Yahas <[EMAIL PROTECTED]>
http://gaal.livejournal.com/

Reply via email to