Wanted to get this out as an idea that could encompass lots of the
concerns I'm seeing about warnings and such:


=head1 TITLE

Warnings and Tainting should be reimplemented as pragmas.

=head1 VERSION

Maintainer: Nathan Wiger <[EMAIL PROTECTED]>
Date: 2 Aug 2000
Version: 1.0
Mailing-List: perl6-language

=head1 ABSTRACT

Currently, tainting and warnings are implemented as singular,
all-or-nothing command-line switches.  These should be reimplemented as
pragmas (like strict) to give better control and more flexibility.

=head1 DESCRIPTION

There has been much talk about wanting finer-grained control over
warnings and possibly tainting as well. Currently, you can only turn
these completely on or off via the -T or -w flags. You can use $^W to
turn all warnings off inside code, but this results in awkward code:

   { local($^W) = 0; do_something() }
   { local($^W) = 0; sub redefine_something { ... } }

Also, *all* warnings are turned off, both "useless" ones (depending on
what you're doing) as well as some that you might actually want to know
about. What would be better is if we could use an approach that was
both:

   1. more human readable
   2. more flexible

I propose we make tainting and warnings into pragas like strict. This
would allow us to do something like this in the simplest case:

   { no warn; do_something() }
   { no taint 'checking'; $ENV{PATH} = possibly_unsafe() }

However, there is far more power in this approach than simply making a
prettier version of $^W. By making it into pragmas, this actually gives
us far more control over warnings. For example, we can split up warnings
into 'vars', 'subs', and so on just like for strict.

So, if we were going to write a module that redefined a whole bunch of
subs, we could just say:

   use strict;
   use warn qw(vars);   

   # no "sub redefined" warning, but still get
   # warnings about unused variables and null vals!
   sub redefine_something { ... }

This cleans up the code, and makes it more obvious what we're doing. It
also allows the flexibility of adding different classes of warnings
going forward (for example, lexical). Finally, as the comment above
shows, we would be able to weed out just certain warnings without
sacrificing them all.

This approach may also be suitable for extending to other areas as well.

=head1 IMPLEMENTATION

If accepted conceptually, I would propose two things:

   1. -T and -w *NOT* go away, but rather act the same
      as 'use taint' and 'use warn'.

   2. That the pragmas be called "warn" and "taint" to
      make them the same tense as "strict".

The warn() function and tainting system would have to be modified. There
are many possiblities for this, and I do not want to address these yet.
Rather, I am interested in the overall like/dislike of this idea.

Reply via email to