What prevent warnings pragma become default feature?

What prevent warnings pragma become default feature by use VERSION?

In Perl 5.12, strict pragma become default feature by use VERSION .

  use v5.12; # enable strict pragma

Now many source code examples in web is written by the following way.

  use v5.x;
  use warnings;

If warnings is enabled by use VERSION, it is useful.

7 Comments

Nothing against it, because most code will use warnings.

But sometimes it is necessary to turn it off, e.g.

  • performance
  • no warnings 'portable'

In short, warnings::register prevents it. In other words you aren't sure about the set of warnings that are going to be enabled implicitly.

Let me add that warnings are often used to detected edge conditions in the program environment (input etc.) while strictures control the program syntax and data flow, so enabling warnings by default everywhere might cause unwanted problems, even if it's generally a good coding practice. (This is also why using fatal warnings in production is an absolute no-go.)

I suspect retro cvompatibility is the issue. If you enable warnings on default you nave to refactor old code to USS no warnings.

If retro compatibility is not an issue, I suspect that Perl developers would have already enabled warnings by default.

On the same line of thoughts, why is not "my" a default for variables?

Why not automatically using a predefined set of modules without having to specify "use"?

The language has been built and evolved in a specific way, so while we can change the future, we cannot destroy the past.

Leave a comment

About Yuki Kimoto

user-pic I'm Perl Programmer. I LOVE Perl. I want to contribute Perl community and Perl users.