develooper Front page | perl.perl5.porters | Postings from November 2019

Re: Miscellaneous suggestions

Thread Previous | Thread Next
Dan Book
November 29, 2019 17:50
Re: Miscellaneous suggestions
Message ID:
On Thu, Nov 28, 2019 at 12:07 PM Dave Mitchell <> wrote:

> =head2 Allow a shortcut for a 'default' default value
> allow $foo? as a shortcut for $foo=undef
>   and $?    as a shortcut for $=
> Similarly for reference aliases,
>     \$s? becomes a shortcut for \$s = undef,
>     \@a? becomes a shortcut for \@a = [],
>     \%h? becomes a shortcut for \%h = {},
> At the same time, ban the existing legal syntax '$=' which means an
> optional placeholder, and allow only the new '$?'. This would make things
> more consistent, as '$foo=' is currently illegal. Also, I find a bare
> trailing equals sign ugly, and it could potentially clash with future
> syntax which might be added to the end of a parameter.

While I don't disagree with this from a design standpoint, I would point
out that of the breaking changes that have been proposed, this is the only
one that could make it difficult to write signatures reusable back to the
5.20 versions in the common case. You could use '$dummy = undef' in both
cases, but it might be nice to continue allowing trailing = and maybe allow
it to go through a deprecation cycle later.


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