Also known as constructs you wish you hadn't discovered.
So, I'm reading through Finkel and I came across the following, which
computes the greatest common divisor of a and b (recast into perl6ish
syntax)
while {
when $a < $b { $b -= $a }
when $b < $a { $a -= $b }
}
The idea is that the loop keeps on looping until none of the guard
conditions match. This can be redone in 'real' Perl 6 as
while 1 {
given 1 {
when $a < $b { $b -= $a }
when $b < $a { $a -= $b }
else { last }
}
}
I'm not sure about the 'break'ing behaviour of a C<when> that isn't in
a C<given> block so I've introduced a 'dummy' one here. Maybe Larry
can clarify.
So, do we want this monstrosity? I confess that I did find myself
using something like it occasionally when I was working on the scheme
evaluator, but it looks very weird indeed.
--
Piers
"It is a truth universally acknowledged that a language in
possession of a rich syntax must be in need of a rewrite."
-- Jane Austen?