Skip to content
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

UNDO always fires for while, until, loop, whenever, with/without, (others too)? #4519

Closed
p6rt opened this issue Sep 6, 2015 · 8 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Sep 6, 2015

Migrated from rt.perl.org#126005 (status was 'resolved')

Searchable as RT126005$

@p6rt
Copy link
Author

p6rt commented Sep 6, 2015

From @raiph

What I did

while ++$ < 3 { UNDO say 'undo'; say 'done' }

What I got

done
undo
done
undo

What I expected

done
done

What I noticed

while, until, loop, and whenever fire the UNDO phaser for their associated block regardless of whether the block succeeds or not.

$*PERL.perl.say shows version => 2015.7.1.735.g.781.c.2.c

@p6rt
Copy link
Author

p6rt commented Sep 6, 2015

From @raiph

while, until, loop, and whenever fire the UNDO phaser for their
associated block regardless of whether the block succeeds or not.

And the with/without constructs too. Maybe others?

@p6rt
Copy link
Author

p6rt commented Dec 21, 2015

From @dakkar

After some investigation, it looks like it's an interaction between the exit_handler (see Perl6​::Metamodel​::BOOTSTRAP) and the VM's implementation of frames (for example, MoarVM's src/core/frame.c, MVM_frame_try_return)

An UNDO block fires at the end of its containing block, if the return value is "null" (nqp​::isnull), not concrete, or not defined. A frame that does not return anything (as a while block seems to be) matches those conditions.

On the other hand, S04 says «The value of a loop statement is the list of values from each iteration».

Open questions​:

- should UNDO fire for void-context, or generally result-less, blocks?
- should while/repeat/whenever have results?

At the moment, this looks to me like a case of "don't do that".

@p6rt
Copy link
Author

p6rt commented Dec 21, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 21, 2015

From @raiph

- should UNDO fire for void-context, or generally result-less, blocks?
- should while/repeat/whenever have results?

At the moment, this looks to me like a case of "don't do that".

On the assumption that it currently doesn't have sane implemented semantics it seems cromulent to say NYI for 6c.

Presumably the same is true for KEEP and any other related phasers that don't work.

@p6rt
Copy link
Author

p6rt commented Dec 23, 2015

From @TimToady

Fixed in 02588190492349fabde00c5a15b873ea61a9333e

Tested in 2f126a3ab7d0991767ca84c562b8f3ae97b25c4e

There are no tests there for with or whenever, but those did not appear to misbehave when I tried them on the command line. Feel free to add more tests for those.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Dec 23, 2015

From @TimToady

Fixed in 02588190492349fabde00c5a15b873ea61a9333e

Tested in 2f126a3ab7d0991767ca84c562b8f3ae97b25c4e

There are no tests there for with or whenever, but those did not appear to misbehave when I tried them on the command line. Feel free to add more tests for those.

@p6rt
Copy link
Author

p6rt commented Dec 23, 2015

@TimToady - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Dec 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant