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

Re: Pre-RFC: yield true feature

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
June 20, 2022 11:41
Subject:
Re: Pre-RFC: yield true feature
Message ID:
20220620124051.750246ee@shy.leonerd.org.uk
On Sun, 19 Jun 2022 13:23:30 +0100
Dave Mitchell <davem@iabyn.com> wrote:

> And here's what I think.
> 
> We should be guided by avoiding, as far as possible, edge/special
> cases, a.k.a. the principle of least surprise.
> 
> So I propose:
> 
> 1) that the yield_true feature is strictly lexically scoped. Because
> otherwise it's a special case.
...

Yeah, I'm with Dave on this. Keeping it as a lexically-scoped one makes
the model simpler for users to understand, writers to document, and
porters to implement.

It already justworks with code written in this style:

  package My::Package::Name;
  use v5.40;

or

  use v5.40;
  package My::Package::Name;

I am willing to bet that >99% of perl files ever encountered are of one
of these two forms.

In the tiny cornercase that people use a toplevel brace structure for
their entire file; 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.

Also I suspect this is the only way it'll work to not upset the "concat
all the .pm files into one script" fatpackers.

-- 
Paul "LeoNerd" Evans

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

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