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

Deprecating downgrade of `use VERSION`

Thread Next
From:
Paul "LeoNerd" Evans
Date:
February 21, 2022 17:29
Subject:
Deprecating downgrade of `use VERSION`
Message ID:
20220221172852.3e9ef635@shy.leonerd.org.uk
I recently added a deprecation warning when you `use VERSION` of a
version under 5.11, after a version at least 5.11 has already been
seen. E.g.

  $ perl5.35.9 
  use v5.30;
  use v5.8;
  Downgrading a use VERSION declaration to below v5.11 is deprecated,
  and will become fatal in Perl 5.40 at - line 2.

That's now in 5.35.9.

I'd like to take it a bit further though, but at the time I wrote it it
was a rush to try to free up some hints bits, so I didn't want to spend
time fully investigating the possible consequences.

What I'd like to propose is a more general deprecation of ever going
backwards. I.e. once you've seen a `use VERSION` of any particular
version number, we don't allow any amount of backwards step. I.e.

  $ hypotheticalperl
  use v5.30;
  use v5.28;
  Downgrading a use VERSION declaration is not permitted at - line 2.

Offhand I can't think of any reason for wanting to do this. Such a
program already declares that it must have a perl v5.30 or above
anyway, so the only usecase is to turn off features/builtins/strict
flags back to an earlier set. If you wanted that, I suggest you could
just

  use v5.28;
  {
    use v5.30;
    # this code has all the features/builtins of 5.30
  }
  # and now we're back to 5.28 again.

To be clear here: This example would be fine because any changes the
inner version declaration had made would be lexical anyway, so falling
out of that inner scope back to the outer one would undo them all. This
is all well-defined without needing to define how `use VERSION` goes
backwards within a given scope.

If we disallow it, then it removes an entire set of questions about how
to handle implicitly-loaded feature/builtin/strict flags that come
along with `use VERSION`.


What do people think? Have I missed a valid use-case for stepping
backwards within the same scope? If not, I propose to make this an
actual deprecation, in order to buy us further thinking-room around any
of these downgrade situations.


-- 
Paul "LeoNerd" Evans

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

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