On Monday, 24 January 2022, 20:22:52 CET, Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote: > You mean like > > use v5.26; > use Syntax::Keyword::MultiSub; > use experimental 'signatures'; > > multi sub max() { return undef; } > multi sub max($x) { return $x; } > multi sub max($x, @more) { my $y = max(@more); > return $x > $y ? $x : $y; } > > -- https://metacpan.org/pod/Syntax::Keyword::MultiSub > > Doesn't yet support `multi method ...` but I keep meaning to get around > to starting implementing that. > > > No, I'm not suggesting we do that, > > Oh, I am ;) What do we do with this? sub max :multi(@args) {...} sub max :multi(%args) {...} Because arrays and hashes flatten into a list, unless @args has an odd number of elements, we can't disambiguate them, can we? Java also has ambiguous cases which fail, but always at compile-time. I don't think we can do that, but I would be delighted to be wrong. Best, Ovid -- IT consulting, training, specializing in Perl, databases, and agile development http://www.allaroundtheworld.fr/. Buy my book! - http://bit.ly/beginning_perlThread Previous | Thread Next