Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^8: Introspecting function signatures

by LanX (Sage)
on Mar 06, 2021 at 22:14 UTC ( #11129219=note: print w/replies, xml ) Need Help??


in reply to Re^7: Introspecting function signatures
in thread Introspecting function signatures

Not sure what Python is implementing with that pattern, but I know it doesn't have block-scope, OTOH nesting functions is easier there.

So many things which are just blocks in Perl become named functions there, even lamda is useless for that.

But no need to copy their limitations.

My suggestion would be to apply attributes or explicit use

sub :test something { my :TEMPDIR $tempdir = shift; # or my :FIXTURE $tempdir = shift; # or use fixture qw/$tempdir/; #... }

This offers plenty of possibilities at compile time and is more flexible than Python's approach.

edit

and I'd certainly put test-subs into their own package, if they lived in the same file.

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

Replies are listed 'Best First'.
Re^9: Introspecting function signatures
by jcb (Parson) on Mar 08, 2021 at 01:58 UTC
    I'd certainly put test-subs into their own package, if they lived in the same file.

    That does not reduce the overhead problem I mentioned — the test-subs will still be compiled every time the module containing them is loaded. Only putting the tests into a separate file solves that problem.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-05-17 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (68 votes). Check out past polls.

    Notices?