Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Distinguish between missing and undefined arguments with subroutine signatures

by dave_the_m (Monsignor)
on Dec 27, 2020 at 19:27 UTC ( [id://11125813]=note: print w/replies, xml ) Need Help??


in reply to Re: Distinguish between missing and undefined arguments with subroutine signatures
in thread Distinguish between missing and undefined arguments with subroutine signatures

P5P is considering to drop the population of @_ when signatures are used
But only after alternative facilities for argument instrospection have been provided. See the proposal on the p5p mailing list.

In particular, in

sub foo($x, ??$has_y, $y = 0) { ... }
$has_y is true if and only if a second arg is passed to the sub.

Dave.

  • Comment on Re^2: Distinguish between missing and undefined arguments with subroutine signatures
  • Download Code

Replies are listed 'Best First'.
Re^3: Distinguish between missing and undefined arguments with subroutine signatures
by jo37 (Deacon) on Dec 27, 2020 at 20:31 UTC
    sub foo($x, ??$has_y, $y = 0) { ... }

    Great! That's it. (Or better: Will be)

    Greetings,
    -jo

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125813]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-24 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found