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

Re: Pre-RFC: yield true feature

Thread Previous | Thread Next
From:
Tony Cook
Date:
June 16, 2022 04:29
Subject:
Re: Pre-RFC: yield true feature
Message ID:
Yqqxm6UFsRESCWar@venus.tony.develop-help.com
On Mon, Jun 06, 2022 at 11:05:59PM +0100, Neil Bowers wrote:
> This is a retrospective Pre-RFC for a proposal from Curtis, for which he submitted a draft RFC[1]. We nearly missed it when reviewing proposals in-flight in our PSC meeting last week, and decided to trigger a discussion here, to reinforce the process.
> 
> Beginning and casual Perl programmers regularly get confused / caught out by the requirement to add `1;` at the end of their modules. To add to their confusion, there are plenty of modules on CPAN with humorous alternatives for "1".
> 
> Curtis proposed a feature called something like yield_true, which would result in the current file yielding a true value on successful compilation. So a module could then look like this:
> 
> 	package Zork;
> 	use feature 'yield_true';
> 
> 	# code
> 
> This is not a feature we’d expect people to use explicitly, but would be part of the version bundle, so you’d get it for free with a future `use v5.XY`.

Thinking about implementation, how should this behave if the included file was:

  package Zork {
      use feature 'yield_true';
  }

remembering features (and use vX.XX) are lexical.

Or perhaps less reasonably:

  package Zork;
  {
      {
          {
              use feature 'yield_true';
          }
      }
  }

The true module on CPAN works by checking the filename between when
"true"->import() is called and when the check function for the
leaveeval is called, which a #line directive might break.

Tony

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