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

Re: Pre-RFC: a `library` keyword

Thread Previous | Thread Next
From:
Dagfinn Ilmari Mannsåker
Date:
April 4, 2022 10:27
Subject:
Re: Pre-RFC: a `library` keyword
Message ID:
87o81hp2ib.fsf@wibble.ilmari.org
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

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