Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
9f3b0ee3
Commit
9f3b0ee3
authored
12 years ago
by
Chris Angelico
Committed by
Henrik (Grubba) Grubbström
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Document the interaction between break and catch
parent
75109362
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
refdoc/chapters/control_structures.xml
+8
-3
8 additions, 3 deletions
refdoc/chapters/control_structures.xml
refdoc/chapters/special_functions.xml
+2
-1
2 additions, 1 deletion
refdoc/chapters/special_functions.xml
with
10 additions
and
4 deletions
refdoc/chapters/control_structures.xml
+
8
−
3
View file @
9f3b0ee3
...
@@ -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"
>
...
...
This diff is collapsed.
Click to expand it.
refdoc/chapters/special_functions.xml
+
2
−
1
View file @
9f3b0ee3
...
@@ -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>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment