New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implicitly returning nothing from a subroutine returns an empty container #4533
Comments
From @thundergnatPost GLR, implicitly returning nothing from a subroutine now returns an perl6 -e' sub h () { return }; my @p = h(); say @p, so @p ' perl6 -e' sub h () { }; my @p = h(); say @p, so @p ' Now if you want to return nothing, you need to do it explicitly. perl6 -e' sub h () { return () }; my @p = h(); say @p, so @p ' perl6 -e' sub h () { () }; my @p = h(); say @p, so @p ' Could be argued that it isn't a bug, but it is surprising to me and is |
From @thundergnatAdded tests to roast. Raku/roast@4841832#diff-900f81c3d5336ef22ff70a27fed79b1d |
From @TimToadyIn C culture, a bare return means "This is a procedure, not a function, and I'm not expecting to return anything", and so I think the absence of a meaningful value is properly conveyed by Nil in Perl 6. If the intent of a return is to allow interpolation of Slip or (), then that choice should be made explicit. Nil is a better default because it doesn't accidentally disappear in an unintended list context. In this sense, Nil can be considered the most basic failure value, designed to trip things up downstream if abused. Roast changes: Raku/roast@cecbb2a9a7 |
The RT System itself - Status changed from 'new' to 'open' |
@TimToady - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#126049 (status was 'rejected')
Searchable as RT126049$
The text was updated successfully, but these errors were encountered: