Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: use v5.36; use warnings;

15 views
Skip to first unread message

Paul "LeoNerd" Evans

unread,
May 28, 2021, 7:45:02 PM5/28/21
to perl5-...@perl.org
On Fri, 28 May 2021 18:54:23 -0400
"Ricardo Signes" <rj...@semiotic.systems> wrote:

> Porters,
>
> Here's an almost simple one:
>
> I propose that `use v5.36` turns on, in addition to strictures and
> the feature bundle, warnings. Specifically, behaves the same as "use
> warnings".

Sounds good.

Also reminder that Leon T has already implemented it:

https://github.com/Perl/perl5/pull/18666

Just needs some documentation.

--
Paul "LeoNerd" Evans

leo...@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/

Darren Duncan

unread,
May 28, 2021, 9:45:03 PM5/28/21
to Perl 5 Porters
On 2021-05-28 6:16 p.m., Ricardo Signes wrote:
> On Fri, May 28, 2021, at 7:37 PM, Paul "LeoNerd" Evans wrote:
>> Also reminder that Leon T has already implemented it:
>>
>> https://github.com/Perl/perl5/pull/18666
>>
>> Just needs some documentation.
>
> I haven't built this yet, and can't tonight, but will soon… but the big question
> for me is what does it do here:
>
> no warnings;
> use v5.35.1;
>
> ?

What I would expect to happen is that the statements are applied in order. So a
"no warnings" above the "use" would have no effect, turning warnings off before
they're turned on again, but having it following the "use" would turn warnings
off after they're turned on. -- Darren Duncan

Darren Duncan

unread,
May 28, 2021, 10:45:03 PM5/28/21
to Perl 5 Porters
On 2021-05-28 7:12 p.m., Ricardo Signes wrote:
> On Fri, May 28, 2021, at 9:29 PM, Darren Duncan wrote:
>> What I would expect to happen is that the statements are applied in order.  So a
>> "no warnings" above the "use" would have no effect, turning warnings off before
>> they're turned on again, but having it following the "use" would turn warnings
>> off after they're turned on. -- Darren Duncan
>
> Except that's not how this works with strict, so the question is where we choose
> to be consistent.

Here's an idea. If a file contains "use 5.36" or higher, and it contains either
"no warnings" or "no strict" above that use line, then a warning will be emitted
that the "no" should be below the "use" rather than above it. This only happens
for programs with "use 5.36" so older programs won't get extra warnings. The
warnings only appear when someone makes the explicit change to add the "5.36"
and then it will say okay you just made that change now make this change. Also
the use warnings behavior will be dependent on order rather than not like use
strict. -- Darren Duncan

L A Walsh

unread,
May 28, 2021, 11:00:03 PM5/28/21
to Perl 5 Porters, Ricardo Signes
On 2021/05/28 15:54, Ricardo Signes wrote:
> I'm torn on whether I think it should behave like the "use vX" behavior of strict, whereby "no strict; use v5.30" does NOT enable strictures.
----
the behavior of "use vX behavior or strict, whereby
'no strict; use v5.30' does NOT enable strictures.

I'm confused, last I heard about 'strict' was that there was an option
in the *configuration* of 5.34 to toggle on 'strict' by default. The
comment
there was:

This setting provides a diagnostic mechanism intended for development
purposes only and is thus undefined by default.

---
So what is this about "use vX" behavior where, when one has "no strict"
before a "use vX" that strictures are NOT enabled? Specifically, does
that imply that a "use vX" without "no strict before it" DOES enable
strictures?

That seems to be a large jump ahead of defining a developmental
configuration option to default them to "on".

In addition to what seems to be "defaulting to strict" under "use Vx"
in "[some?]" version of perl you are asking if warnings should be on as
well?

If strictures are on by default, does that mean they are fatal as they
are now?

OB semantics:
how would 'use vX' know there was a "no strict" before the use
statement, vs. there being no "use strict"?

Before commenting on anything else, I hope the above is clarified...


Darren Duncan

unread,
May 29, 2021, 9:00:04 PM5/29/21
to Perl 5 Porters
On 2021-05-29 7:11 a.m., Ricardo Signes wrote:
> In other words, "use vX" turns on strict if X is at least 5.12.0, unless it was
> preceded by "no strict".
>
> 3️⃣ I am proposing that putting "use v5.36.0" (or later) in your program will
> *also* enable warnings
>
> …and then the question is: will "use v5.36.0" have the same quirk of not turning
> on warnings if it was preceded by "no warnings"?

To answer your question, I am proposing that the behaviour of "no strict" prior
to the "use" is a mistake not to be repeated, and that reasonable actions are
taken to mitigate that mistake.

So "no warnings" will NOT behave the same as "no strict", and rather "no
warnings" will only have an effect if it FOLLOWS something that turns warnings on.

As for the inconsistency this would raise with "no strict", I propose the
solution is simply to emit a warning in any program that has a "no strict" prior
to a "use 5.36" and the warning would say the statements should be reordered so
the "no strict" appears afterwards.

That solution means actual programs are consistent in appearance and behavior.
While "no strict" would still suppress strict if used first, anyone attempting
to use it would be warned to stop doing so, and so that behavior becomes unused.

-- Darren Duncan

Martijn Lievaart

unread,
May 30, 2021, 9:15:02 AM5/30/21
to perl5-...@perl.org

Op 30-05-2021 om 02:43 schreef Darren Duncan:
> As for the inconsistency this would raise with "no strict", I propose
> the solution is simply to emit a warning in any program that has a "no
> strict" prior to a "use 5.36" and the warning would say the statements
> should be reordered so the "no strict" appears afterwards.
>
> That solution means actual programs are consistent in appearance and
> behavior. While "no strict" would still suppress strict if used first,
> anyone attempting to use it would be warned to stop doing so, and so
> that behavior becomes unused.
>

I would say this is the most sensible solution.


M4


Scott Baker

unread,
May 31, 2021, 4:00:03 PM5/31/21
to perl5-...@perl.org

I support enabling `warnings` with `use v5.36` 1000%. I'm surprised we didn't already do it. I only see it as a net positive.

I don't know if the `no warnings; use v5.36` is worth the effort? I can't think of a real world scenario where you'd want one without the other. And if you did you can enable features one by one. If it's easy then we should do it... but I wouldn't want to spend too much time on it.

Please make this happen.

- Scott

On 5/28/21 3:54 PM, Ricardo Signes wrote:
Porters,

Here's an almost simple one:

I propose that use v5.36 turns on, in addition to strictures and the feature bundle, warnings.  Specifically, behaves the same as "use warnings".

I'm torn on whether I think it should behave like the "use vX" behavior of strict, whereby "no strict; use v5.30" does NOT enable strictures.  Probably, just for the sake of reducing the number of exceptions -- but if we fold more things into use vX, we need to decide if they all need to be tracked this way.

-- 
rjbs

L A Walsh

unread,
May 31, 2021, 9:30:03 PM5/31/21
to Perl 5 Porters, Ricardo Signes
On 2021/05/29 07:11, Ricardo Signes wrote:
> On Fri, May 28, 2021, at 10:49 PM, L A Walsh wrote:
>
>> Before commenting on anything else, I hope the above is clarified...
>>
> I'm afraid I had a really hard time understanding your post, so I'm going to try the old strategy of stating all the facts that might be relevant.
>
> 1️⃣ strict is not on by default in any version of perl5 and this is not changing.
> Example code:
> perl -e '$x = 1'
> 2️⃣ since perl v5.12.0, "use v5.12.0" has enabled strict, *unless it was explicitly disabled first*
>

---
This clarifies my misunderstanding.

I've virtually never used:
'use v5.12.0' #(or any other version) *without*

prior lines (or immediately after):
use warnings;use strict;

So I wasn't aware that use strict was already toggled on before such.


I find it a bit odd that having the use-version after
the no-strict wouldn't toggle it back on if
'use strict' was advertised being part of the 5.12 bundle.

I'm not sure I understand why that was done that way, since it would
seem to violate normal perl semantics.


I'm assuming that the order:

use v5.12.0;
no strict;

Would also result in 'strict being off'?
Is it also the case that a "use version" statement, for any version
>5.12.0, also toggles on strict, but is similarly silenced by a 'no
strict' on either side of the 'use'?









David Cantrell

unread,
Jun 3, 2021, 9:15:03 AM6/3/21
to perl5-...@perl.org
On Sat, May 29, 2021 at 10:11:34AM -0400, Ricardo Signes wrote:

> In other words, "use vX" turns on strict if X is at least 5.12.0, unless it was preceded by "no strict".
>
> 3?????? I am proposing that putting "use v5.36.0" (or later) in your program will *also* enable warnings
>
> ???and then the question is: will "use v5.36.0" have the same quirk of not turning on warnings if it was preceded by "no warnings"?

I'd prefer "use vX" to *ignore* the current strictness/warningness and
always turn 'em on, but I realise it's too late to change now.

So I would suggest that if we're going to have confusing behaviour - ie
"use vX" sometimes turns something on, sometimes not - then we should
have *consistent* confusing behaviour.

--
David Cantrell | Cake Smuggler Extraordinaire

If you can't imagine how I do something, it's
because I have a better imagination than you

Paul "LeoNerd" Evans

unread,
Jun 18, 2021, 5:30:03 PM6/18/21
to Ricardo Signes, Perl 5 Porters
On Fri, 18 Jun 2021 15:24:41 -0400
"Ricardo Signes" <perl...@rjbs.manxome.org> wrote:

> I think we should declare that "use vX" does this:
> * use feature ":default"; use feature ":X";
> * use xyz; (for various xyz);
> That means it would unconditionally turn on strict. If we add
> warnings, it will unconditionally turn on warnings.

That all sounds quite good, yes.

It's also a much simpler mental model for everyone - each declaration
might fiddle with things, but they all do so in written order.
`use VERSION` might twiddle a lot of things that a later more specific
`no strict 'this'; no warnings 'that';` turns off again.

It also suggests a good general rule - put the `use VERSION` first
thing in the file, then the other use/no pragmata after it.

That's what I in fact already do. :)

Martijn Lievaart

unread,
Jun 21, 2021, 2:45:03 PM6/21/21
to perl5-...@perl.org
Op 29-05-2021 om 04:29 schreef Darren Duncan:
This seems like a good way out of this conundrum. It solves all problems.


M4


0 new messages