This is PerlMonks "Mobile"

Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  


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.