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

Re: Pre-RFC: a `library` keyword

Thread Previous | Thread Next
From:
Yuki Kimoto
Date:
April 5, 2022 03:56
Subject:
Re: Pre-RFC: a `library` keyword
Message ID:
CAExogxNGdJVRasbDjOd5dbF=3dMGazBnUfby=HvsHG2SohrW7g@mail.gmail.com
2022-4-4 19:27 Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> wrote:

> Yuki Kimoto <kimoto.yuki@gmail.com> writes:
>
> > I ask a question about  yield_true feature.
> >
> > This example seems to be adding "1;" to the end of the file scope.
> >
> > Can yield_true feature be implemented actually as a file scope, not as a
> > global scope?
>
> All features (as in feature.pm) are lexically scoped, the file scope is
> just the top-level lexical scope.  This implies that doing `use feature
> 'yield_true';` in a non-toplevel scope, i.e. inside a sub or other
> block, has no effect, since the feature will not be enabled anymore at
> the end of the file scope.
>
> - ilmari
>

Thank you for your reply.

Can I understand the yield_true feature as the following example?

  {
    use feature 'yield_true';
    {
      print "Hello';
    }
  }

is same as

  {
    {
      print "Hello';
    }
    1;
  }

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