Mailing List Archive

use warnings ':most'
I would like to propose to add a new warning category, tentatively named
"most". This would include everything in :all except warnings that are
likely to give false positives. In 5.36 that would be :all minus 'once',
but I can imagine more warnings being added to :all in the future that
wouldn't be appropriate for :most.

Secondly, I want «use warnings» without a tag to do :most instead of :all,
and likewise «use 5.36;».

Leon
Re: use warnings ':most' [ In reply to ]
On Wed, Jun 2, 2021 at 7:02 PM Leon Timmermans <fawaka@gmail.com> wrote:

> I would like to propose to add a new warning category, tentatively named
> "most". This would include everything in :all except warnings that are
> likely to give false positives. In 5.36 that would be :all minus 'once',
> but I can imagine more warnings being added to :all in the future that
> wouldn't be appropriate for :most.
>
> Secondly, I want «use warnings» without a tag to do :most instead of :all,
> and likewise «use 5.36;».
>

+1. The same design needed for this can allow adding optional warnings
which are not enabled by "use warnings" or "use vX" but can be explicitly
requested. I think whether it uses the existing 'all' name is an
implementation detail because that name is rarely used by users. Previous
discussion: https://github.com/Perl/perl5/issues/18543

-Dan
Re: use warnings ':most' [ In reply to ]
On Thu, 3 Jun 2021 01:02:25 +0200
Leon Timmermans <fawaka@gmail.com> wrote:

> I would like to propose to add a new warning category, tentatively
> named "most". This would include everything in :all except warnings
> that are likely to give false positives. In 5.36 that would be :all
> minus 'once', but I can imagine more warnings being added to :all in
> the future that wouldn't be appropriate for :most.
>
> Secondly, I want «use warnings» without a tag to do :most instead of
> :all, and likewise «use 5.36;».
>
> Leon

An excellent idea.

In fact it was an excellent idea in 2015 when RJBS suggested it:

https://www.nntp.perl.org/group/perl.perl5.porters/2015/10/msg231858.html

Twice

https://www.nntp.perl.org/group/perl.perl5.porters/2015/06/msg228400.html

Nay, three times:

https://www.nntp.perl.org/group/perl.perl5.porters/2015/01/msg225066.html

and other times by other people going back years.

I agreed back then and I agree now.

Maybe this time around we'll get it off the ground? Good luck...

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: use warnings ':most' [ In reply to ]
On 3/6/21 1:02, Leon Timmermans wrote:
> I would like to propose to add a new warning category, tentatively named
> "most". This would include everything in :all except warnings that are
> likely to give false positives. In 5.36 that would be :all minus 'once',
> but I can imagine more warnings being added to :all in the future that
> wouldn't be appropriate for :most.
>
> Secondly, I want «use warnings» without a tag to do :most instead of
> :all, and likewise «use 5.36;».

What would happen with user defined warning categories?

For instance, imagine Foo defines its own warnings

use 5.36;
use Foo qw(foo_number); # calls "use warnings::register Foo"
# under the hood!

foo_number("hello");

Would that generate a warning? Would Foo author be able to decide if Foo
goes with ':most' or not?
Re: use warnings ':most' [ In reply to ]
On Thu, 3 Jun 2021 09:20:43 +0200
Salvador Fandiño <sfandino@gmail.com> wrote:

> Would that generate a warning? Would Foo author be able to decide if
> Foo goes with ':most' or not?

I believe the idea of "most" is really "all except 'once' because we
find that not helpful", so I expect it would do the same with "most" as
it does for "all".

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: use warnings ':most' [ In reply to ]
On Thu, Jun 03, 2021 at 01:02:25AM +0200, Leon Timmermans wrote:

> I would like to propose to add a new warning category, tentatively named
> "most". This would include everything in :all except warnings that are
> likely to give false positives. In 5.36 that would be :all minus 'once',
> but I can imagine more warnings being added to :all in the future that
> wouldn't be appropriate for :most.
>
> Secondly, I want ?use warnings? without a tag to do :most instead of :all,
> and likewise ?use 5.36;?.

While I think that a 'most' category is a good idea, I'm not so sure
that we could get agreement on what should be in it!

And now that we have negative imports on the warnings pragma is it
needed so much?

Your preferred 'most' can be expressed as ...

use warnings qw(all -once);

My preferred 'most' can be expressed as ...

use warnings qw(all -redefine -experimental::signatures);

--
David Cantrell | semi-evolved ape-thing

Irregular English:
ladies glow; gentlemen perspire; brutes, oafs and athletes sweat
Re: use warnings ':most' [ In reply to ]
On Thu, Jun 3, 2021 at 8:54 AM David Cantrell <david@cantrell.org.uk> wrote:

> On Thu, Jun 03, 2021 at 01:02:25AM +0200, Leon Timmermans wrote:
>
> > I would like to propose to add a new warning category, tentatively named
> > "most". This would include everything in :all except warnings that are
> > likely to give false positives. In 5.36 that would be :all minus 'once',
> > but I can imagine more warnings being added to :all in the future that
> > wouldn't be appropriate for :most.
> >
> > Secondly, I want «use warnings» without a tag to do :most instead of
> :all,
> > and likewise «use 5.36;».
>
> While I think that a 'most' category is a good idea, I'm not so sure
> that we could get agreement on what should be in it!
>
> And now that we have negative imports on the warnings pragma is it
> needed so much?
>
> Your preferred 'most' can be expressed as ...
>
> use warnings qw(all -once);
>
> My preferred 'most' can be expressed as ...
>
> use warnings qw(all -redefine -experimental::signatures);
>

The purpose is not to appease a preference (as there are clearly many of
those and they can call warnings.pm how they want), but to change the
behavior of 'use warnings;' and eventually 'use VERSION;' by default. The
proposal here is that 'once' would not be included by default.

-Dan
Re: use warnings ':most' [ In reply to ]
Perhaps this has already been covered:

Would we have tags for the warnings available with a given Perl version,
following a similar pattern to feature.pm?

If so, would we expect that `use v5.36` would enable warnings equivalent to
`use warnings ':5.36'`, and be (highly?) likely not to enable unexpected
new warnings in future? ("guarantee" would be overly strong here, maybe in
future there's a new warnings category that's seen as being something that
should be turned on by default).

>
Re: use warnings ':most' [ In reply to ]
On Thu, Jun 3, 2021 at 11:39 AM Tom Molesworth via perl5-porters <
perl5-porters@perl.org> wrote:

> Perhaps this has already been covered:
>
> Would we have tags for the warnings available with a given Perl version,
> following a similar pattern to feature.pm?
>
> If so, would we expect that `use v5.36` would enable warnings equivalent
> to `use warnings ':5.36'`, and be (highly?) likely not to enable unexpected
> new warnings in future? ("guarantee" would be overly strong here, maybe in
> future there's a new warnings category that's seen as being something that
> should be turned on by default).
>

This seems like a lot of infrastructure for something of limited use (but
feel free to propose it as a new feature). Perl has never provided any
guarantees of warnings staying consistent, in documentation or in practice.

-Dan
Re: use warnings ':most' [ In reply to ]
On Wed, Jun 2, 2021 at 7:02 PM Leon Timmermans <fawaka@gmail.com> wrote:

> I would like to propose to add a new warning category, tentatively named
> "most". This would include everything in :all except warnings that are
> likely to give false positives. In 5.36 that would be :all minus 'once'
>

"once" is exactly the kind of warning a newcomer should have enabled.

A user performing advanced symbol table manipulation has no problems
turning off "once" when needed.

Secondly, I want «use warnings» without a tag to do :most instead of :all
>

This is backwards incompatible, and it hurts newcomers.

The advanced user will know to use :most if that's what they want. The
newcomer is suddenly told about fewer likely problems.
Re: use warnings ':most' [ In reply to ]
On Sun, Jun 6, 2021 at 2:38 AM Eric Brine <ikegami@adaelis.com> wrote:

> On Wed, Jun 2, 2021 at 7:02 PM Leon Timmermans <fawaka@gmail.com> wrote:
>
>> I would like to propose to add a new warning category, tentatively named
>> "most". This would include everything in :all except warnings that are
>> likely to give false positives. In 5.36 that would be :all minus 'once'
>>
>
> "once" is exactly the kind of warning a newcomer should have enabled.
>
> A user performing advanced symbol table manipulation has no problems
> turning off "once" when needed.
>

I was thinking of "redefine".

But why would you want to turn off "once" warning?!
Re: use warnings ':most' [ In reply to ]
On Sun, Jun 6, 2021 at 2:38 AM Eric Brine <ikegami@adaelis.com> wrote:

> On Wed, Jun 2, 2021 at 7:02 PM Leon Timmermans <fawaka@gmail.com> wrote:
>
>> I would like to propose to add a new warning category, tentatively named
>> "most". This would include everything in :all except warnings that are
>> likely to give false positives. In 5.36 that would be :all minus 'once'
>>
>
> "once" is exactly the kind of warning a newcomer should have enabled.
>
> A user performing advanced symbol table manipulation has no problems
> turning off "once" when needed.
>
> Secondly, I want «use warnings» without a tag to do :most instead of :all
>>
>
> This is backwards incompatible, and it hurts newcomers.
>
> The advanced user will know to use :most if that's what they want. The
> newcomer is suddenly told about fewer likely problems.
>

If not enabled by default, ':most' is entirely pointless. The purpose is to
improve the default when applied via bare 'use warnings' or 'use VERSION',
since that is what almost all code uses.

Changes to warnings do not break compatibility by policy. This doesn't mean
we should change them willy nilly, and changes to the interface can still
break compatibility, but warnings themselves are added and adjusted in
every release, removing them from the default is the same.

'once' warnings are not useful to newcomers, as they only (unreliably)
occur when writing code that uses package variables.

-Dan
Re: use warnings ':most' [ In reply to ]
On Sun, Jun 6, 2021 at 3:05 AM Dan Book <grinnz@gmail.com> wrote:

> On Sun, Jun 6, 2021 at 2:38 AM Eric Brine <ikegami@adaelis.com> wrote:
>
>> On Wed, Jun 2, 2021 at 7:02 PM Leon Timmermans <fawaka@gmail.com> wrote:
>>
>>> I would like to propose to add a new warning category, tentatively named
>>> "most". This would include everything in :all except warnings that are
>>> likely to give false positives. In 5.36 that would be :all minus 'once'
>>>
>>
>> "once" is exactly the kind of warning a newcomer should have enabled.
>>
>> A user performing advanced symbol table manipulation has no problems
>> turning off "once" when needed.
>>
>> Secondly, I want «use warnings» without a tag to do :most instead of :all
>>>
>>
>> This is backwards incompatible, and it hurts newcomers.
>>
>> The advanced user will know to use :most if that's what they want. The
>> newcomer is suddenly told about fewer likely problems.
>>
>
> If not enabled by default, ':most' is entirely pointless. The purpose is
> to improve the default when applied via bare 'use warnings' or 'use
> VERSION', since that is what almost all code uses.
>
> Changes to warnings do not break compatibility by policy. This doesn't
> mean we should change them willy nilly, and changes to the interface can
> still break compatibility, but warnings themselves are added and adjusted
> in every release, removing them from the default is the same.
>
> 'once' warnings are not useful to newcomers, as they only (unreliably)
> occur when writing code that uses package variables.
>

To add, my view is that "optional warnings", however they may be
implemented, would be those warnings which are useful for someone, but
annoying for most (and thus commonly result in warnings being disabled
entirely due to pointless noise). We don't have a lot of these currently
because, since all warnings are enabled by 'use warnings', developers have
been careful not to introduce unnecessarily noisy warnings. But with a
mechanism where they aren't enabled unless requested, it is then reasonable
to add such.

-Dan
Re: use warnings ':most' [ In reply to ]
Eric Brine <ikegami@adaelis.com> wrote:

> But why would you want to turn off "once" warning?!

{ no warnings 'once'; $DB::single = 1; }

That's tells the perl debugger you want to pause at that point in the code.
It's good for skipping past a lot of initialization (I don't have any interest
in stepping through the code for Moo, for example), and does nothing at
all if you're not running the debugger. This single use of "single" is
guaranteed to produce a "once" warning if you don't silence it.

I would say a bigger problem is the 'uninitialized' warning, but I gather that
one's not on the table.
Re: use warnings ':most' [ In reply to ]
On Wed, Jun 2, 2021, at 7:20 PM, Paul "LeoNerd" Evans wrote:
> In fact it was an excellent idea in 2015 when RJBS suggested it:
> […]
> Twice
> […]
> Nay, three times:
> […]

…and I still think that "use v5.X" should mean "use warnings 'default'" and that default should exist.

I think it should mean what "all" means now, though, including "once." Let's first *create* default, meaning all the current warnings, then we can separately discuss what warnings might get excluded?

--
rjbs
Re: use warnings ':most' [ In reply to ]
On Sun, Jun 6, 2021 at 4:03 PM Ricardo Signes <perl.p5p@rjbs.manxome.org>
wrote:

> On Wed, Jun 2, 2021, at 7:20 PM, Paul "LeoNerd" Evans wrote:
>
> In fact it was an excellent idea in 2015 when RJBS suggested it:
> […]
> Twice
> […]
> Nay, three times:
> […]
>
>
> …and I still think that "use v5.X" should mean "use warnings 'default'"
> and that default should exist.
>
> I think it should mean what "all" means now, though, including "once."
> Let's first *create* default, meaning all the current warnings, then we
> can separately discuss what warnings might get excluded?
>

I don't think 'default' is a good name for it, since it's already used to
describe warnings which are enabled without any use of the warnings pragma
(e.g. severe and deprecation warnings).

-Dan
Re: use warnings ':most' [ In reply to ]
On Sun, Jun 6, 2021 at 10:15 PM Dan Book <grinnz@gmail.com> wrote:

> On Sun, Jun 6, 2021 at 4:03 PM Ricardo Signes <perl.p5p@rjbs.manxome.org>
> wrote:
>
>> …and I still think that "use v5.X" should mean "use warnings 'default'"
>> and that default should exist.
>>
>> I think it should mean what "all" means now, though, including "once."
>> Let's first *create* default, meaning all the current warnings, then we
>> can separately discuss what warnings might get excluded?
>>
>
> I don't think 'default' is a good name for it, since it's already used to
> describe warnings which are enabled without any use of the warnings pragma
> (e.g. severe and deprecation warnings).
>
> -Dan
>

Agreed. Probably someone can come up with a better than than 'most', but
'default' is kind of confusing (and 'standard' may also be)

Leon
Re: use warnings ':most' [ In reply to ]
> On Jun 6, 2021, at 16:31, Leon Timmermans <fawaka@gmail.com> wrote:
>
> ?
>> On Sun, Jun 6, 2021 at 10:15 PM Dan Book <grinnz@gmail.com> wrote:
>>> On Sun, Jun 6, 2021 at 4:03 PM Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
>>
>>> …and I still think that "use v5.X" should mean "use warnings 'default'" and that default should exist.
>>>
>>> I think it should mean what "all" means now, though, including "once." Let's first create default, meaning all the current warnings, then we can separately discuss what warnings might get excluded?
>>
>> I don't think 'default' is a good name for it, since it's already used to describe warnings which are enabled without any use of the warnings pragma (e.g. severe and deprecation warnings).
>>
>> -Dan
>
> Agreed. Probably someone can come up with a better than than 'most', but 'default' is kind of confusing (and 'standard' may also be)

use warnings ':5.36'?

-F
Re: use warnings ':most' [ In reply to ]
From the keyboard of Leon Timmermans [03.06.21,01:02]:

> I would like to propose to add a new warning category, tentatively named "most". This would
> include everything in :all except warnings that are likely to give false positives. In 5.36
> that would be :all minus 'once', but I can imagine more warnings being added to :all in the
> future that wouldn't be appropriate for :most.
>
> Secondly, I want «use warnings» without a tag to do :most instead of :all, and likewise
> «use 5.36;».
>
> Leon

I proppose another approach, since most people will have different ideas
about what ":most" should mean. I'd introduce negating warnings at 'use'
by prefixing the category or warning with a dash

use warnings qw(-once); # enables all warnings except 'once'

which is just a lazy way to say

use warnings;
no warnings 'once';

That way everbody can roll his own warning exceptions in an easy way.
I'd boilerplate my stuff with

use warnings (
'all',
'-once',
'-redefine',
'-uninitialized',
);

which gives a clear message of the evil things I'm doing, and I can
turn on warnings by just switching the first blank to a '#' in devel
mode. Does this sound reasonable?

0--gg-

--
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: use warnings ':most' [ In reply to ]
On Sun, Jun 6, 2021 at 6:34 PM shmem <gm@qwurx.de> wrote:

> From the keyboard of Leon Timmermans [03.06.21,01:02]:
>
> > I would like to propose to add a new warning category, tentatively named
> "most". This would
> > include everything in :all except warnings that are likely to give false
> positives. In 5.36
> > that would be :all minus 'once', but I can imagine more warnings being
> added to :all in the
> > future that wouldn't be appropriate for :most.
> >
> > Secondly, I want «use warnings» without a tag to do :most instead of
> :all, and likewise
> > «use 5.36;».
> >
> > Leon
>
> I proppose another approach, since most people will have different ideas
> about what ":most" should mean. I'd introduce negating warnings at 'use'
> by prefixing the category or warning with a dash
>
> use warnings qw(-once); # enables all warnings except 'once'
>
> which is just a lazy way to say
>
> use warnings;
> no warnings 'once';
>
> That way everbody can roll his own warning exceptions in an easy way.
> I'd boilerplate my stuff with
>
> use warnings (
> 'all',
> '-once',
> '-redefine',
> '-uninitialized',
> );
>
> which gives a clear message of the evil things I'm doing, and I can
> turn on warnings by just switching the first blank to a '#' in devel
> mode. Does this sound reasonable?


This is already a feature (recently added) except that it won't enable
warnings you didn't specify explicitly:
https://perldoc.perl.org/warnings#%22Negative-warnings%22

But this doesn't address the issue at hand, which is adjusting what is
enabled by default by "use warnings;" or "use VERSION;".

-Dan
Re: use warnings ':most' [ In reply to ]
On Sun, Jun 6, 2021, at 4:14 PM, Dan Book wrote:
> On Sun, Jun 6, 2021 at 4:03 PM Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:__
>> …and I still think that "use v5.X" should mean "use warnings 'default'" and that default should exist.
>>
>> I think it should mean what "all" means now, though, including "once." Let's first *create* default, meaning all the current warnings, then we can separately discuss what warnings might get excluded?
>
> I don't think 'default' is a good name for it, since it's already used to describe warnings which are enabled without any use of the warnings pragma (e.g. severe and deprecation warnings).

Yes, quite right. I still don't care for "most", and propose either "recommended" or "standard", but I will punt further name debate until we have an implementation. ????

--
rjbs
Re: use warnings ':most' [ In reply to ]
On Mon, Jun 7, 2021 at 2:15 AM Ricardo Signes <perl.p5p@rjbs.manxome.org>
wrote:

> On Sun, Jun 6, 2021, at 4:14 PM, Dan Book wrote:
>
> On Sun, Jun 6, 2021 at 4:03 PM Ricardo Signes <perl.p5p@rjbs.manxome.org>
> wrote:
>
> …and I still think that "use v5.X" should mean "use warnings 'default'"
> and that default should exist.
>
> I think it should mean what "all" means now, though, including "once."
> Let's first *create* default, meaning all the current warnings, then we
> can separately discuss what warnings might get excluded?
>
>
> I don't think 'default' is a good name for it, since it's already used to
> describe warnings which are enabled without any use of the warnings pragma
> (e.g. severe and deprecation warnings).
>
>
> Yes, quite right. I still don't care for "most", and propose either
> "recommended" or "standard", but I will punt further name debate until we
> have an implementation. ????
>

The leont/most-warnings branch adds it. I think it doesn't enable custom
warnings yet though, should we want that.

Leon
Re: use warnings ':most' [ In reply to ]
On Sun, 6 Jun 2021 18:40:29 -0400
Dan Book <grinnz@gmail.com> wrote:

> This is already a feature (recently added) except that it won't enable
> warnings you didn't specify explicitly:
> https://perldoc.perl.org/warnings#%22Negative-warnings%22

Surely a oneline fix for that:

unshift @args, ":all" if @args and $args[0] =~ m/^-/;

> But this doesn't address the issue at hand, which is adjusting what is
> enabled by default by "use warnings;" or "use VERSION;".

Agreed.

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: use warnings ':most' [ In reply to ]
Here's another thread with discussion after the previous attempt to
implement this:
https://www.nntp.perl.org/group/perl.perl5.porters/2014/12/msg224127.html

On Wed, Jun 2, 2021 at 6:21 PM Paul "LeoNerd" Evans
<leonerd@leonerd.org.uk> wrote:
>
> On Thu, 3 Jun 2021 01:02:25 +0200
> Leon Timmermans <fawaka@gmail.com> wrote:
>
> > I would like to propose to add a new warning category, tentatively
> > named "most". This would include everything in :all except warnings
> > that are likely to give false positives. In 5.36 that would be :all
> > minus 'once', but I can imagine more warnings being added to :all in
> > the future that wouldn't be appropriate for :most.
> >
> > Secondly, I want «use warnings» without a tag to do :most instead of
> > :all, and likewise «use 5.36;».
> >
> > Leon
>
> An excellent idea.
>
> In fact it was an excellent idea in 2015 when RJBS suggested it:
>
> https://www.nntp.perl.org/group/perl.perl5.porters/2015/10/msg231858.html
>
> Twice
>
> https://www.nntp.perl.org/group/perl.perl5.porters/2015/06/msg228400.html
>
> Nay, three times:
>
> https://www.nntp.perl.org/group/perl.perl5.porters/2015/01/msg225066.html
>
> and other times by other people going back years.
>
> I agreed back then and I agree now.
>
> Maybe this time around we'll get it off the ground? Good luck...
>
> --
> Paul "LeoNerd" Evans
>
> leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
> http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/