Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Length of Array Passed as Reference

by tobyink (Canon)
on Dec 10, 2020 at 09:21 UTC ( #11124935=note: print w/replies, xml ) Need Help??


in reply to Re: Length of Array Passed as Reference
in thread Length of Array Passed as Reference

Or:

use feature 'state'; use Types::Standard -types; use Type::Params 'compile'; sub test_function { state $signature = compile( ArrayRef[Str] ); my ( $ref ) = &$signature; # function body goes here }

The signature will check that the function was passed the correct number of arguments, the correct types, etc, and die if it wasn't.

Replies are listed 'Best First'.
Re^3: Length of Array Passed as Reference
by eyepopslikeamosquito (Bishop) on Dec 10, 2020 at 10:49 UTC

    Nice. It seems to me your API embraces "Declarative trumps Imperative" (one of Conway's seven API design tips, mentioned at On Interfaces and APIs).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2021-10-27 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (94 votes). Check out past polls.

    Notices?