develooper Front page | perl.perl5.porters | Postings from June 2022

Signature feature request (pre-rfc?)

Thread Next
June 6, 2022 21:05
Signature feature request (pre-rfc?)
Message ID:
Hi all,

I've just hit a weird edge case in some code I'm writing that requires a
lot of meta programming. In this case, I have two separate modules which
require this:

    sub _internal_func ( $class, $params ) { ... }

But the second class requires this:

    sub _internal_func ($class) { ... }

So those signatures aren't quite compatible. For the second module, my
workaround is this:

    sub _internal_func ( $class, $params = undef ) { ... }

But I'm not using $params at all for the second module, meaning I need to
declare. scalar I'm not using. I now need to document in the code why this
has happened. I'd like to write this:

    sub _internal_func ( $class, undef ) { ... }

But that turns out to be a syntax error, even though it's a common idiom:

    my ( $package, undef, $caller ) = caller;

Since the argument list in subroutine names is effectively the same as a my
declaration, can we unify them to have the same syntax and thus be less

CTO, All Around the World
World-class software development and consulting

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About