There is nothing exactly like wantarray in Perl 6. Functions can no longer return different values based on context, because as Darren mentioned above, it's a Bad Thing.
There are a few ways of doing something similar by returning mixins, perhaps something like return $num but [$num, $num2]; (which for some reason doesn't seem to work in rakudo right now) But this is probably not a good idea, anyway. It would be better to replace it with a clear interface for a new module, rather than reproducing old context sensitive code. After all, Perl 6 is all about breaking Perl 5 idioms to fix them, why stop with the compiler? On Thu, Mar 19, 2015 at 3:53 PM, Darren Duncan <dar...@darrenduncan.net> wrote: > I think as a general principle, multi methods should dispatch entirely on > their parameter signatures, and dispatching on return type is just a bad > design that leads to trouble. If you want different return types for > identical parameters, you should give those 2 versions different method > base names. -- Darren Duncan > > > On 2015-03-19 3:20 PM, Tom Browder wrote: > >> I need to replace the Perl 5 'wantarray' and think a multi method with >> differing return types should do it. >> >> So I've tried this: >> >> multi method foo($a, $b --> {Num,Num}) { #... } >> multi method foo($a, $b --> Num) { #... } >> >> and get errors like: >> >> Missing block >> at Ellipsoid.pm:672 >> ------> ethod to($lat1, $lon1, $lat2, $lon2 --> �{Rat, Rat}) >> from test_ellipsoid.pl:12 >> >> I've tried parentheses, square brackets, and no grouping characters >> instead of curly braces but that doesn't change the error. >> >> Question: >> >> How does one properly provide differing function return type signatures? >> >> Thanks. >> >> Best, >> >> -Tom >> >> >