develooper Front page | perl.perl5.porters | Postings from January 2020

Re: 'use warnings' with exceptions

Thread Previous | Thread Next
From:
David Cantrell
Date:
January 27, 2020 17:26
Subject:
Re: 'use warnings' with exceptions
Message ID:
20200127172556.GA840@bytemark.barnyard.co.uk
On Mon, Jan 27, 2020 at 10:40:19AM -0500, Dan Book wrote:
> On Mon, Jan 27, 2020 at 6:19 AM David Cantrell <david@cantrell.org.uk>
> wrote:
> >   use warnings qw(-foo -bar);
> > to mean "import all the warnings except foo and bar". But it seems not
> > to be. Before I put fingers to keyboard and implement it does anyone
> > think it's a terrible idea?
> I like the idea, but I think first we need to resolve the question, all
> warnings or default warnings? (It's already a difficulty to add new
> warnings without making them default, let's not make it harder...)

What I wanted was for 'use warnings qw(-foo)' to mean the same as plain
old 'use warnings' but without 'foo'.

If the user says 'use warnings qw(foo -bar)' then that should I think
just turn on the 'foo' warning, and turn off the '-bar' warning.

If you've already got some warnings turned on but then in some
restricted scope want to turn 'foo' warnings off - that's what
'no warnings qw(foo)' is for.

So, this:

  use warnings qw(-foo -bar);

would be equivalent to:

  use warnings qw(all);
  no warnings qw(foo bar);

and this:

  use warnings qw(foo bar -baz -barf);

would be equivalent to:

  use warnings qw(foo bar);
  no warnings qw(baz barf);

... and that's what I implemented while waiting for tests to run:
  https://github.com/Perl/perl5/pull/17500 

-- 
David Cantrell | Hero of the Information Age

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