On Tue, 28 Jun 2022 10:29:13 +0100 Dave Mitchell <davem@iabyn.com> wrote: > So I now think that the single change in > behaviour in perl should be: ... > to: > > if 'require_returns_true' was in scope at the point where > require explicitly or implicitly returned: > > throw away the return value and return !!1 to the caller > of 'require' > > else > > as before: if the return value is false, croak, else > return the value to the caller of 'require'. Yes; that all sounds sensible. > I'm not convinced that having a warning when returning a false value > would be useful. I suspect that most uses of 'use v5.40' will be in > new code (rather than retrofitting an existing module) where a > warning won't be particularly useful. Instead it could generate false > positives - for example, if the last line in Foo.pm file is: > > $Foo::some_flag = calc_flag(); > > then the warning will surface only if calc_flag() returns false, > which might not happen during testing. > > So such a warning would only potentially be useful in old code which > has been retrofitted with 'use v5.40', and then only on those rare > modules which actually use a false return to signal failure. I think > this is rare enough to not outweigh the problem of false positives in > new code. Also agree. This feels like it's veering towards some kind of agreement enough that we should write up a real RFC for the idea. That, and my "lexically_export" should keep me busy today ;) -- 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