2022-4-5 17:06 Graham Knop <haarg@haarg.org> wrote: > On Tue, Apr 5, 2022 at 5:56 AM Yuki Kimoto <kimoto.yuki@gmail.com> wrote: > > > > > > > > 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; > > } > > > > It wouldn't make any sense for this to apply to inner blocks. It would > only apply to the end of the file. Since the feature would usually be > enabled at the beginning of a file, it would be in effect for all > inner blocks. Having all inner blocks in a file return true would not > make sense. > > There is more discussion about this potential feature on the RFC: > https://github.com/Perl/RFCs/pull/16 Could the conversion of Pre-RFC of "yield_true" be done in another thread of p5p?Thread Previous | Thread Next