On Wed, 19 Jan 2022 17:59:41 +0000, "Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote: > * As a variant of the above; you can't even see the count of passed > arguments in order to distinguish no-argument from being explicitly > passed undef (or whatever the param default is) > > sub not_signatured { > my ($x) = @_; > warn "X was " ? (@_ ? "the value $x" : "not passed"); > } > > sub signatured ($x = undef) { > # impossible to distinguish signatured () from signatured (undef) > } FWIW: this is also impossible in raku. I have requested a feature to detect this, but it was declined then (years ago) because it was blocking possible optimizations in "hiding" the argument hash. With signatures and named arguments, this is much more complicated than the example you give: method foo (Int :$x, Int :$y = 42, Bool :$z = False) { } foo (x => 1, z => False); foo (y => 42, :$z); You cannot use arity to check *what* named argument was passed and if it was assigned a default value or if the caller passed the default value. -- H.Merijn Brand https://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.33 porting perl5 on HP-UX, AIX, and Linux https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.orgThread Previous | Thread Next