From 9f3b0ee32a9c22d94b2070b4d13d3ae0e469318c Mon Sep 17 00:00:00 2001 From: Chris Angelico <rosuav@gmail.com> Date: Sat, 30 Jun 2012 17:47:12 +1000 Subject: [PATCH] Document the interaction between break and catch --- refdoc/chapters/control_structures.xml | 11 ++++++++--- refdoc/chapters/special_functions.xml | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/refdoc/chapters/control_structures.xml b/refdoc/chapters/control_structures.xml index 17008183f0..4af6274307 100644 --- a/refdoc/chapters/control_structures.xml +++ b/refdoc/chapters/control_structures.xml @@ -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> <subsection title="break"> -<p><tt>break</tt> exits a loop or switch statement immediately and continues -executing after the loop. <tt>Break</tt> can not be used outside of a loop or -switch. It is quite useful in conjunction with <tt>while(1)</tt> to +<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 one of these. +It is quite useful in conjunction with <tt>while(1)</tt> to construct command parsing loops for instance:</p> <example> @@ -326,6 +326,11 @@ a:if(sizeof(arr1) >= sizeof(arr2)) // execution continues here } </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 title="continue"> diff --git a/refdoc/chapters/special_functions.xml b/refdoc/chapters/special_functions.xml index c1084a4009..869c5d6668 100644 --- a/refdoc/chapters/special_functions.xml +++ b/refdoc/chapters/special_functions.xml @@ -35,7 +35,8 @@ The description of the error has the following format:</p> }) </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> <example> -- GitLab