develooper Front page | perl.perl5.porters | Postings from June 2015

Re: for 5.24: new categories for strict/warnings?

Thread Previous | Thread Next
June 5, 2015 15:42
Re: for 5.24: new categories for strict/warnings?
Message ID:
Ricardo Signes writes:

> What is preventing us from changing the meaning of:
>   use warnings;  # which means: use warnings 'all'
> Why not make [it] mean:
>   use warnings 'default';

I'm concerned that'll just recreate one of the current problems in a few
years' time, and that it might be better for plain use warnings to mean:

  use warnings 'v5.22';

Scenarios we may wish to support include:

• Cautious Upgrader:  Tallulah has a large warning-free codebase running
  under Perl 5.22. When she upgrades to 5.24 she doesn't want any
  additional warnings.

• Reckless Upgrader:  When Charley upgrades he wants his code to warn
  about all possible issues, including those that previous versions
  didn't warn about.

• Modern Developer:  Eddie starts writing a new program (no back compat
  concerns) on Perl 5.24. He wants all the help he can get from any
  warnings that are available.

Until now, everybody does just use warnings. If Perl adds new warnings,
Tallulah loses; if it doesn't, Eddie and Charley lose.

With Rik's suggested change, Tallulah can do a plain use warnings, and
avoid any 5.24-introduced warnings, and Charley can do use warnings
'all' to get everything. Yay!

However, if Eddie does a plain use warnings, he misses out on
potentially useful recently added warnings. To get the new warnings,
Eddie has to use warnings 'all' ... which is fine for now.

But then 5.26 is released, with additional new warnings. If Eddie
upgrades, he's ended up putting himself in the ‘Reckless Upgrader’
group, which wasn't his intention.

What Eddie really wants is ‘Give me all the warnings for the version of
Perl I've written this for, but not any warnings added in later
versions’. (Right now of course that's equivalent to the ossified
5.20-era warnings that Rik's change would tag as 'default', but only
because no further warnings have been introduced yet.)

If the current 'all' warnings were relabelled as 'v5.22' and new warnings
added into appropriately versioned labels, then Tallulah could still
safely upgrade her existing code which says:

  use v5.22;
  use warnings;

and Charley would still be fine with:

  use warnings 'all';

Eddie could then write:

  use v5.24;
  use warnings 'v5.24';

to get the new warnings in v5.24 but not be at risk of unexpected
warnings on upgrading to v5.26.

But it's awkward that Eddie has to write v5.24 twice there. In practice
most people would want the same number in both places, and it'd be
unfortunate that you'd have to know to request new warnings to get them.

It'd be better for a plain use warnings to mean ‘the warnings of
whichever version I've specified, defaulting to v5.22 if none’. Then
Eddie can get his desired behaviour with:

  use v5.24;
  use warnings;

On finding itself invoked without any tags, warnings would then see that
use v5.24 has been specified, and so behave like use warnings 'v5.24'.

That way Perl can safely introduce new warnings every version, and users
get to benefit from the new warnings straightforwardly, yet people can
still upgrade cautiously.


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