develooper Front page | perl.perl5.porters | Postings from March 2023

Re: strictness and "use 5.whatever"

Thread Previous | Thread Next
From:
Zefram via perl5-porters
Date:
March 8, 2023 13:11
Subject:
Re: strictness and "use 5.whatever"
Message ID:
ZAiJYhYOktMYE0Za@fysh.org
Paul "LeoNerd" Evans wrote:
>                                   We'd quite like to get those bits
>back as we're running out of them.

There are less disruptive options there.  The feature bits thing from 5.32
can be extended to arbitrarily many flags, providing a quickly-accessible
copy (in an array of as many U32s as necessary, in the COP structure)
of flags that semantically live in %^H.  It can also be extended without
much effort to bitfields bigger than a single bit, should the need arise.
(That would be useful if one wanted to identify the feature bundle as
a thing, as is currently done with a few bits of $^H, but with all the
individual features now representable by their own quickly-accessible
bits, it doesn't seem useful any more to represent the bundles in that
bundled manner.)

>Secondly, there's the ease with which it can be explained to users.
...
>Thus, *with this change in strict in place*, we can confidently tell
>users that
>
>  use v5.40;
>
>is really exactly equivalent to
>
>  use strict;
...

You can have "use v5.40" mean exactly that anyway.  There is no need to
change the meaning of "use v5.16" to achieve that.  Sure, by changing
it you can make the meaning of "use v5.16" easier to explain, except no
you can't, because that easier explanation only applies on Perl 5.40+,
so the real explanation of "use v5.16" would then start with "it does
different things depending on which Perl version you're running" and would
incorporate the explanation of the current meaning.  But presumably you
don't really need "use v5.16" to be easier to explain, because you're
not advising people to start new programs with that.

I suggest that you start with the new semantics now.  "use v5.37.10",
and the equivalent for any higher accepted version, can set the
"explicitly-set" stricture bits, making it truly equivalent to a bunch
of pragmata that include "use strict".

>                    The equivalent code for strict isn't possible to
>write down exactly because of the complex interaction between the
>implicit and the explicit shadow bits.

Yes, that is an infelicity of the established meanings for "use v5.16"
et al.  It's fixable without changing the meanings of anything: we
could easily implement some kind of pragma that explicitly controls the
stricture bits in the same manner.  Obviously there isn't much call for
that kind of pragma as something for people to use directly, but it would
have this explanatory value, and might have some use in metapragmata.
(The version pragmata are essentially metapragmata.)

The new pragma could be a completely new module, even a third-party thing
on CPAN, but I think it would be nicest as a new subpragma of strict.pm.
"use strict 'softly'", "use strict softly => 'refs'", that sort of thing.
There's nothing stopping you explaining historical version pragmata
in terms of a new pragma that wasn't available on the historical Perl
versions.

>Offhand while I write this I can't remember what the reason for
>disallowing back-stepping was,

I'd be interested in learning the real motivation.  It's looking like
there'll be a better answer to whatever the problem was.

-zefram

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