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

Re: Signature feature request (pre-rfc?)

Thread Previous | Thread Next
Darren Duncan
June 7, 2022 08:51
Re: Signature feature request (pre-rfc?)
Message ID:
On 2022-06-06 2:04 p.m., Ovid wrote:
> 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 feel that this should be documented anyway, even if you do get the "undef" 
syntax you requested.  If you have a routine whose caller interface requires 
passing an argument that actually isn't used, something common with 
multiple-implemented APIs, that should be documented. -- Darren Duncan

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