Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes and adds example refs #1268
  • Loading branch information
JJ committed Jun 24, 2019
1 parent a0c8ad1 commit c5f83a8
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions doc/Type/CX/Next.pod6
Expand Up @@ -6,11 +6,34 @@
role CX::Next does X::Control { }
A L<control exception|/language/exceptions#Control_exceptions> to be used to
proceed to the next iteration; since Rakudo 2019.03, C<throw>ing an
C<X::Control> object raises a control exception which is caught by the
L<CONTROL phaser|/language/phasers#CONTROL> instead of
L<CATCH|/language/phasers#CATCH>.
A L<control exception|/language/exceptions#Control_exceptions> that is triggered
when C<next> is called; since Rakudo 2019.03, C<throw>ing an C<X::Control>
object raises a control exception which can be caught by the L<CONTROL
phaser|/language/phasers#CONTROL> instead of L<CATCH|/language/phasers#CATCH>.
=for code
for ^10 {
CONTROL {
when CX::Next { say "We're next" };
}
next if $_ %% 2;
say "We're in $_";
}
This will print:
=for code :lang<text>
We're next
We're in 1
We're next
We're in 3
We're next
We're in 5
We're next
We're in 7
We're next
We're in 9
=head1 Methods
Expand Down

4 comments on commit c5f83a8

@b2gills
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rakudo 2019.03 added the ability for user defined objects to work with CONTROL.

CX::Next has always worked with CONTROL.

@JJ
Copy link
Contributor Author

@JJ JJ commented on c5f83a8 Jun 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always, as in...? I'll have to check when it was introduced. The phrasing does not talk about the introduction of CX::Next, but the fact that exceptions are captured by CONTROL and not by CATCH (or maybe besides)

@b2gills
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the CX:: exceptions are old and worked with CONTROL from the beginning.

Only the ability for a user defined object to work with CONTROL is new.

@JJ
Copy link
Contributor Author

@JJ JJ commented on c5f83a8 Jun 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that the sentence was already there from the beginning. I replicated it for no good reason, however. I'll raise an issue and see how we can fix it.

Please sign in to comment.