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

Re: The explicit strict hints bits - Can we remove them?

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
February 5, 2022 02:29
Subject:
Re: The explicit strict hints bits - Can we remove them?
Message ID:
20220205022928.7d4ef44c@shy.leonerd.org.uk
On Thu, 3 Feb 2022 22:23:13 +0000
"Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote:

> I would much rather just remove the behaviour entirely.
> 
> We could get rid of the HINT_EXPLICIT_STRICT_* bits altogether, and
> simply state that a `use VERSION` of any number 5.12-or-above is
> *exactly* equivalent to `use strict`, or a number 5.10-or-earlier is
> exactly `no strict`. This would let us simplify our implementation,
> tests, and most importantly user-facing documentation around the `use
> VERSION` syntax. And it would gain us three precious hints bits back
> for other purposes.
> 
> 
> Thoughts, anyone?

We discussed this at PSC today and this generally seems the right thing
to do.

One additional thought is that it should print a warning when you
downgrade the `use VERSION` in these cases where the behaviour now
changes.

I now have a WIP branch doing just so:

  https://github.com/leonerd/perl5/tree/deprecate-downgrading-use-version

It behaves as:

  $ ./perl -e 'use v5.35.9; use v5.8;'
  Downgrading a use VERSION declaration to below v5.11 is now deprecated
  at -e line 1.

But this is fine:

  $ ./perl -ce 'use v5.35.9; use v5.12;'
  -e syntax OK

It is lexically scoped, so this is also fine:

  $ ./perl -ce '{ use v5.35.9; } use v5.8;'
  -e syntax OK

And it of course only gets upset about downgrades; upgrades are fine:

  $ ./perl -ce 'use v5.6; use v5.8; use v5.14'
  -e syntax OK


It's quite conservative and only prints a warning if the downgrade
actually matters for possible `strict` interactions - i.e. you're
requesting a version below v5.11 and there has already been a version
above that previously.

(*Personally* I think the warning should be printed on *any* downgrade
at all, but various folks have argued that might be a bit too
restrictive for now, so I haven't done that.)

Once I get this branch fully working (it fails some tests currently)
I'll pop some proper documentation into it and send a PR, as a
pre-requisite for getting rid of the EXPLICIT_STRICT hints bits, at
which point we'll have three spare.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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