Aaron Sherman <[EMAIL PROTECTED]> writes: > On Thu, 2002-09-12 at 06:46, Piers Cawley wrote: > >> Here's the classic example of mutual recursion: >> >> sub even ($n) { >> given $n { >> when 0 { return 1 }; >> default { odd($n-1) }; >> } >> } >> >> sub odd ($n) { >> given $n { >> when 0 { return } >> default { even($n-1) }; >> } >> } >> >> even(2); >> >> Which throws C<< [prefix::val (not implemented) even] Prefix operator odd >> >> while compiling the tree. Curse! >> > > That's because the compiler does not currently handle the case of > calling a function before it's defined. Use: > > sub odd($n); > > first to declare the function. This gets you a warning about redefining > odd, but that's ignorable.
Odd... could have sworn I tried that. And I was under the impression that official format for this was C<< sub odd($n) {...} >>, which definitely doesn't work. -- 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?