Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^8: Distinguish between missing and undefined arguments with subroutine signatures (methods with signatures?)

by jo37 (Deacon)
on Dec 27, 2020 at 21:53 UTC ( [id://11125839]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Distinguish between missing and undefined arguments with subroutine signatures (methods with signatures?)
in thread Distinguish between missing and undefined arguments with subroutine signatures

If you are talking about compile-time checking ...

No, I'm not talking about compile-time checking. I want method call checking at runtime. My sig_lexical example does what I want, but I'm not sure if this is a legal usage.

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
  • Comment on Re^8: Distinguish between missing and undefined arguments with subroutine signatures (methods with signatures?)
  • Download Code

Replies are listed 'Best First'.
Re^9: Distinguish between missing and undefined arguments with subroutine signatures (methods with signatures?)
by LanX (Saint) on Dec 27, 2020 at 21:59 UTC
    > I want method call checking at runtime

    I can't follow anymore.

    You want 1 argument for a setter, and 0 arguments for a getter.

    Hence you need a conditional check anyway.

    So use a @slurpy parameter and check the size at runtime.

    Then die "too many arguments" if @slurpy > 1

    Problem solved.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-24 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found