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

Re: Signature feature request (pre-rfc?)

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
June 7, 2022 14:10
Subject:
Re: Signature feature request (pre-rfc?)
Message ID:
Yp9cKq6NzLr99JGp@iabyn.com
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 = []

etc.

Under that scheme, 

    $?

would become an alternative for

    $=


-- 
I before E. Except when it isn't.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About