Skip to content
Snippets Groups Projects
Commit 9f3b0ee3 authored by Chris Angelico's avatar Chris Angelico Committed by Henrik (Grubba) Grubbström
Browse files

Document the interaction between break and catch

parent 75109362
No related branches found
No related tags found
No related merge requests found
...@@ -292,9 +292,9 @@ that is still missing is the ability to exit a loop in the middle of it. ...@@ -292,9 +292,9 @@ that is still missing is the ability to exit a loop in the middle of it.
There are three ways to do this:</p> There are three ways to do this:</p>
<subsection title="break"> <subsection title="break">
<p><tt>break</tt> exits a loop or switch statement immediately and continues <p><tt>break</tt> exits a loop, switch, or catch statement immediately and continues
executing after the loop. <tt>Break</tt> can not be used outside of a loop or executing after the loop. <tt>Break</tt> can not be used outside of one of these.
switch. It is quite useful in conjunction with <tt>while(1)</tt> to It is quite useful in conjunction with <tt>while(1)</tt> to
construct command parsing loops for instance:</p> construct command parsing loops for instance:</p>
<example> <example>
...@@ -326,6 +326,11 @@ a:if(sizeof(arr1) >= sizeof(arr2)) ...@@ -326,6 +326,11 @@ a:if(sizeof(arr1) >= sizeof(arr2))
// execution continues here // execution continues here
} }
</example> </example>
<p>Inside a <tt>catch</tt> block, <tt>break</tt> will terminate the block with no
exception being thrown; <tt>catch</tt> will return zero, as if execution had
continued to the end of the block.</p>
</subsection> </subsection>
<subsection title="continue"> <subsection title="continue">
......
...@@ -35,7 +35,8 @@ The description of the error has the following format:</p> ...@@ -35,7 +35,8 @@ The description of the error has the following format:</p>
}) })
</example> </example>
<p>If no error occurs, catch will return zero. You may emulate your own errors <p>If no error occurs, or if the <ref>break</ref> statement is
encountered, catch will return zero. You may emulate your own errors
using the function throw or error.</p> using the function throw or error.</p>
<example> <example>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment