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.


How does one properly provide differing function return type signatures?




Reply via email to