develooper Front page | perl.perl5.porters | Postings from July 2021

Re: Elevator pitch, deprecating $a/$b sort globals by using sub{}

Thread Previous | Thread Next
From:
Dan Book
Date:
July 4, 2021 17:14
Subject:
Re: Elevator pitch, deprecating $a/$b sort globals by using sub{}
Message ID:
CABMkAVVoG20gmTAi2Yxu-6m9UW88gAcFxF-kYW4U64Kn89+nVQ@mail.gmail.com
On Sun, Jul 4, 2021 at 1:09 PM John Ankarström <john@ankarstrom.se> wrote:

> Den 2021-07-04 kl. 17:40 skrev Martijn Lievaart:
> > Karl Wiliamson's remarks about $a/$b as a quirk got me thinking. With
> > signatures as a language feature it's feasable to make sort not only
> > take a blok or a subroutine name, but also a sub. That means $a and $b
> > for sort can be deprecated in the long run, and eventually turned off
> > with a feature flag if we so choose.
>
> This is a difficult question.  I think that Perl is used in two ways:
>
>    1. For building small scripts.
>    2. For building large programs.
>
> This duality means that the design of the language has to be carefully
> balanced.  "Small" Perl favors implicitness, "big" Perl favors
> strictness.  In some cases, they're mutually incompatible, and it is
> important that neither concern be favored to the detriment of the other,
> lest an important significant part of Perl users become disillusioned.
>
> In the past, the strict variant of Perl has been the answer to this
> divide.  Keeping in mind desires among users of "big" Perl for more
> strictness, I think one of the following solutions should be considered:
>
>    1. Implicit $a/$b should be disabled when 'use strict' is active.
>    2. Implicit $a/$b should be disabled by a new pragma, 'use stricter'
>       = 'use strict' plus any number of further strictures.
>
> The drawback of (2) is that it divides the Perl language even further,
> but the benefit is that much more strictness, such as that suggested
> here, could be added to Perl without any controversy.  It would satisfy
> "big" Perl while not upsetting "small" Perl.
>
> (My personal opinion is that implicit $a/$b is too useful to remove from
> strict Perl.)
>
>
Unfortunately $a and $b are in far too much use in programs that use strict
for 1 to be at all feasible. 2 is the only option (and it would likely
instead be a specific feature, which could be implicitly enabled by other
constructs).

-Dan

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