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
Make 'return;' *actually* return #127
Conversation
|
This way ends up with us having different code paths for return with an argument and return without. Furthermore, it means that the places you can use one or the other are different (anywhere a term is valid for the existing prefix, vs. top level statement for the other case). I think the righter answer is to unify both, as a term:sym that optionally takes an argument (parsed with ? or so). |
|
I agree, I prefer a single path and not separate ones. Pm On Wed, Sep 18, 2013 at 07:24:35AM -0700, Jonathan Worthington wrote:
|
|
I would also prefer a single sub my-sub() {
say('here');
return;
say('there');
}When I tried this over the weekend (for debugging reasons), the return was simply skipped over, leading to much confusion on my part. It took me a while to figure out what was going on, and I wanted to spare future NQP developers that confusion. |
|
Then perhaps That can be done in the existing grammar rule without too much Pm |
|
@pmichaud the "return needs an argument" thing does catch people out. Even me. :-) So we should fix it, really. We can't so easily detect it with the exist grammar rule 'cus it parses as a prefix operator. I mean, we could do a lookahead like <!before <.ws> <[;}]>> or so...but that feels a little icky.. |
|
@jnthn then yes, switching return to be a term with an optional argument can work also, I suppose. At any rate, I prefer only one code path for parsing 'return', however it ends up. |
|
@jnthn Wouldn't something like |
|
@arnsholt Yes, foo(return 1) is valid Perl 6. |
|
Oh, in that case it's perfectly okay of course. Are the semantics of |
|
Identical. Note that while that's not the most useful example, useful is like |
This way, 'return;' won't be silently ignored in a function. Closes #127.
No description provided.