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

Re: Signature feature request (pre-rfc?)

Thread Previous | Thread Next
Dave Mitchell
June 7, 2022 14:10
Re: Signature feature request (pre-rfc?)
Message ID:
On Mon, Jun 06, 2022 at 11:04:59PM +0200, Ovid wrote:
>     sub _internal_func ( $class, undef ) { ... }
> But that turns out to be a syntax error, even though it's a common idiom:

Signatures already support an unnamed optional placeholder:

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

although the syntax is a bit jarring.

As an aside, one of my proposals is for 'default defaults' i.e. where the
default value for an optional arg is omitted and a sensible default is
substituted instead (e.g. when expecting an array ref arg, the default
value might be []). So,

    $foo? is a shortcut for  $foo = undef
    \@a?  is a shortcut for  \@a = []


Under that scheme, 


would become an alternative for


I before E. Except when it isn't.

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