# New Ticket Created by David Warring
# Please include the string: [perl #128108]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=128108 >
Rakudo is pretty good at parsing literal arguments as positional parameters.
For example:
multi sub s(True) { 'case1' } # Bool $ where $_
multi sub s('fred') { 'case2' } # Str $ where 'fred'
multi sub s(42) {'case3' } # Int $ where 42
for 1+1==2, 'fred', 42 -> $val {
say s($val)
}
#case1
#case2
#case3
If I refactor the above from a positional to a named parameter, then I need to
be a bit more explicit. Something like:
multi sub s(Bool :$val! where $_) { '#case1' }
multi sub s(Str :$val! where 'fred') { '#case2' }
multi sub s(Numeric :$val! where 42) { '#case3' }
for 1+1==2, 'fred', 42 -> $val {
say s(:$val)
}
Can the handling of named arguments be improved to more like the positional
case? I was hoping for something like:
multi sub s(:val) { "#case1" }
multi sub s(:val<fred>) { "#case2" }
multi sub s(:val(42)) { "#case3" }
Or something similar (None of these parse at the moment).