develooper Front page | perl.perl5.porters | Postings from June 2022

Re: Pre-RFC: yield true feature

Thread Previous | Thread Next
From:
Martijn Lievaart
Date:
June 21, 2022 09:22
Subject:
Re: Pre-RFC: yield true feature
Message ID:
597c6374-2379-42ef-3087-b2ee27a43b87@rtij.nl
Op 21-06-2022 om 10:02 schreef Ovid:
> On Mon, Jun 20, 2022 at 1:41 PM Paul "LeoNerd" Evans 
> <leonerd@leonerd.org.uk> wrote:
>
>     On Sun, 19 Jun 2022 13:23:30 +0100
>
>     In the tiny cornercase that people use a toplevel brace structure for
>     their entire file; a.la <http://a.la>.
>
>       package My::Package::Name {
>         use v5.40;
>       }
>
>     then maybe we just tell them "hey, don't do that. There's no need to".
>
>     That structure does also give people a real valid escape hatch in case
>     they genuinely did not want that feature.
>
>
> Uh oh. I do that quite a bit and more and more of my code examples are 
> like that. I like knowing that I have a proper lexical block there to 
> encapsulate things. To me, the fact that the following prints "3" is a 
> feature I prefer to avoid:
>
>     package Foo; my $x = 3;
>     package Bar; say $x;
>
> If I switch those to postfix blocks, it won't compile.


I may be missing something, but wouldn't


use v5.78;

package Foo {}

package Bar {}


Fix that? In fact, why would you do:


package Foo {

     use v5.34;

}

package Bar {

     use 5.36;

}

which is the only reason I can think of to put the use inside the 
package declaration, if the versions would differ.


HTH,

M4



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