# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #129768]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=129768 >


<seatek> Hello :) So, wondering if anyone might know - in a parameter
signature, if you have a slurpy array (*@thing) -- is there a way to
define a default set of values for it, if nothing gets slurped up?
<seatek> sub MAIN ( Str :$log-file = 'blah', Bool :$thing = False,
@srcDirs = ('/tmp', '/var/log' ))
<seatek> that would give the error
<seatek> Cannot put optional positional parameter @srcDirs after
variadic parameters
<seatek> and if you give it the slurpy splat, it's the same error message
<masak> seatek: I agree that "it's the same error message" is more
confusing than it has to be
<masak> m: sub MAIN (:$named, *@srcDirs = ("/tmp", "/var/log" )) {}
<camelia> rakudo-moar 83d733: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤Cannot put optional positional parameter @srcDirs
after variadic parameters [...]
<masak> seatek: what it really should do in the case of the slurpy is
to give you the error "Cannot put default on slurpy parameter
@srcDirs"
<masak> m: sub MAIN (*@srcDirs = ("/tmp", "/var/log" )) {}
21:07 <+camelia> rakudo-moar 83d733: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤Cannot put default on slurpy parameter @srcDirs [...]
<masak> ...which it does if you don't put named parameters before it
<masak> seatek: I think as to your original question -- whether it's
supported -- the answer is no because you basically can not *not* pass
in a set of values to the slurpy parameter.
<seatek> masak: yeah, that makes complete sense when you really think about it

Reply via email to