Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Control flow
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Loop system cross-reference table ===<!-- See also Category:Programming language comparisons. --> {| class="wikitable" |- ! rowspan=2 |[[Programming language]] ! colspan=3 | conditional ! colspan=4 | loop ! rowspan=2 | early exit ! rowspan=2 | loop continuation ! rowspan=2 | redo ! rowspan=2 | retry ! colspan=2 | correctness facilities |- ! begin ! middle ! end ! count ! collection ! general ! infinite {{ref_label|loop_infinite|1|a}} ! variant ! invariant |- | [[Ada (programming language)|Ada]] | {{yes}} | {{yes}} | {{yes}} | {{yes}} | {{partial|arrays}} | {{no}} | {{yes}} | {{yes|deep nested}} | {{no}} | | | | |- | [[APL (programming language)|APL]] | {{yes}} | {{no}} | {{yes}} | {{yes}} | {{yes}} | {{yes}} | {{yes}} | {{partial|deep nested}} {{ref_label|deep_break_c|3|a}} | {{yes}} | {{no}} | {{no}} | | |- | [[C (programming language)|C]] | {{yes}} | {{no}} | {{yes}} | {{no}} {{ref_label|loop_for|2|a}} | {{no}} | {{yes}} | {{no}} | {{partial|deep nested}} {{ref_label|deep_break_c|3|a}} | {{partial|deep nested}} {{ref_label|deep_break_c|3|a}} | {{no}} | | | |- | [[C++]] | {{yes}} | {{no}} | {{yes}} | {{no}} {{ref_label|loop_for|2|b}} | {{yes}} {{ref_label|loop_foreach|9|a}} | {{yes}} | {{no}} | {{partial|deep nested}} {{ref_label|deep_break_c|3|b}} | {{partial|deep nested}} {{ref_label|deep_break_c|3|a}} | {{no}} | | | |- | [[C Sharp (programming language)|C#]] | {{yes}} | {{no}} | {{yes}} | {{no}} {{ref_label|loop_for|2|c}} | {{yes}} | {{yes}} | {{no}} | {{partial|deep nested}} {{ref_label|deep_break_c|3|c}} | {{partial|deep nested}} {{ref_label|deep_break_c|3|a}} | | | | |- | [[COBOL]] | {{yes}} | {{no}} | {{yes}} | {{yes}} | {{no}} | {{yes}} | {{no}} | {{partial|deep nested}} {{ref_label|cobol_deep_exit|15|a}} | {{partial|deep nested}} {{ref_label|cobol_deep_exit|14|a}} | {{no}} | | | |- | [[Common Lisp]] | {{yes}} | {{yes}} | {{yes}} | {{yes}} | {{partial|builtin only}} {{ref_label|cl_sequence_type|16|a}} | {{yes}} | {{yes}} | {{yes|deep nested}} | {{no}} | | | | |- | [[D (programming language)|D]] | {{yes}} | {{no}} | {{yes}} | {{yes}} | {{yes}} | {{yes}} | {{yes}}{{ref_label|DInfinite|14|a}} | {{yes|deep nested}} | {{yes|deep nested}} | {{no}} | | | |- | [[Eiffel (programming language)|Eiffel]] | {{yes}} | {{no}} | {{no}} | {{yes}} {{ref_label|count_loop_eiffel|10|a}} | {{yes}} | {{yes}} | {{no}} | {{partial|one level}} {{ref_label|count_loop_eiffel|10|a}} | {{no}} | {{no}} | {{no}} {{ref_label|retry_in_eiffel|11|a}} | {{partial|integer only}} {{ref_label|integer_variant|13|a}} | {{yes}} |- | [[F Sharp (programming language)|F#]] | {{yes}} | {{no}} | {{no}} | {{yes}} | {{yes}} | {{no}} | {{no}} | {{no}} {{ref_label|deep_break_e|6|b}} | {{no}} | {{no}} | | | |- | [[FORTRAN 77]] | {{yes}} | {{no}} | {{no}} | {{yes}} | {{no}} | {{no}} | {{no}} | {{partial|one level}} | {{yes }} | {{no}} | {{no}} | | |- | [[Fortran 90]] | {{yes}} | {{no}} | {{no}} | {{yes}} | {{no}} | {{no}} | {{yes}} | {{yes|deep nested}} | {{yes|deep nested}} | {{no}} | {{no}} | | |- | [[Fortran 95]] and later | {{yes}} | {{no}} | {{no}} | {{yes}} | {{partial|arrays}} | {{no}} | {{yes}} | {{yes|deep nested}} | {{yes|deep nested}} | {{no}} | {{no}} | | |- | [[Go (programming language)|Go]] | {{yes}} | {{no}} | {{no}} | {{yes}} | {{partial|builtin only}} | {{yes}} | {{yes}} | {{yes|deep nested}} | {{yes|deep nested}} | {{no}} | | | |- | [[Haskell]] | {{no}} | {{no}} | {{no}} | {{no}} | {{yes}} | {{no}} | {{yes}} | {{no}} {{ref_label|deep_break_e|6|a}} | {{no}} | {{no}} | | | |- | [[Java (programming language)|Java]] | {{yes}} | {{no}} | {{yes}} | {{no}} {{ref_label|loop_for|2|d}} | {{yes}} | {{yes}} | {{no}} | {{yes|deep nested}} | {{yes|deep nested}} | {{no}} | |{{yes|non-native}} {{ref_label|requires_JML|12|a}} |{{yes|non-native}} {{ref_label|requires_JML|12|a}} |- | [[JavaScript]] | {{yes}} | {{no}} | {{yes}} | {{no}} {{ref_label|loop_for|2|g}} | {{yes}} | {{yes}} | {{no}} | {{yes|deep nested}} | {{yes|deep nested}} | {{no}} | | |- | Natural | {{yes}} | {{yes}} | {{yes}} | {{yes}} | {{no}} | {{yes}} | {{yes}} | {{yes}} | {{yes}} | {{yes}} | {{no}} | |- | [[OCaml]] | {{yes}} | {{no}} | {{no}} | {{yes}} | {{yes|arrays,lists}} | {{no}} | {{no}} | {{no}} {{ref_label|deep_break_e|6|b}} | {{no}} | {{no}} | | | |- | [[PHP]] | {{yes}} | {{no}} | {{yes}} | {{no}} {{ref_label|loop_for|2|e}} {{ref_label|loop_for|5|b}} | {{yes}} {{ref_label|loop_phpforeach|4|a}} | {{yes}} | {{no}} | {{yes|deep nested}} | {{yes|deep nested}} | {{no}} | | | |- | [[Perl]] | {{yes}} | {{no}} | {{yes}} | {{no}} {{ref_label|loop_for|2|f}} {{ref_label|loop_for|5|c}} | {{yes}} | {{yes}} | {{no}} | {{yes|deep nested}} | {{yes|deep nested}} | {{yes}} | | | |- | [[Python (programming language)|Python]] | {{yes}} | {{no}} | {{no}} | {{no}} {{ref_label|loop_range|5|a}} | {{yes}} | {{no}} | {{no}} | {{partial|deep nested}} {{ref_label|deep_break_e|6|c}} | {{partial|deep nested}} {{ref_label|deep_break_e|6|c}} | {{no}} | | | |- | [[Rebol]] | {{no}} {{ref_label|while|7|a}} | {{yes}} | {{yes}} | {{yes}} | {{yes}} | {{no}} {{ref_label|user|8|a}} | {{yes}} | {{partial|one level}} {{ref_label|deep_break_e|6|d}} | {{no}} | {{no}} | | | |- | [[Ruby (programming language)|Ruby]] | {{yes}} | {{no}} | {{yes}} | {{yes}} | {{yes}} | {{no}} | {{yes}} | {{partial|deep nested}} {{ref_label|deep_break_e|6|e}} | {{partial|deep nested}} {{ref_label|deep_break_e|6|e}} | {{yes}} | {{yes}} | | |- | [[Standard ML]] | {{yes}} | {{no}} | {{no}} | {{no}} | {{yes|arrays,lists}} | {{no}} | {{no}} | {{no}} {{ref_label|deep_break_e|6|b}} | {{no}} | {{no}} | | | |- | [[Visual Basic .NET]] | {{yes}} | {{no}} | {{yes}} | {{yes}} | {{yes}} | {{no}} | {{yes}} | {{partial|one level per type of loop}} | {{partial|one level per type of loop}} | | | | |- | [[PowerShell]] | {{yes}} | {{no}} | {{yes}} | {{no}} {{ref_label|loop_for|2|h}} | {{yes}} | {{yes}} | {{no}} | {{dunno}} | {{yes}} | | | | |} # {{note label|loop_infinite|1|a}} <code>while (true)</code> does not count as an infinite loop for this purpose, because it is not a dedicated language structure. # {{note label|loop for|2|a}}{{note_label|loop_for|2|b}}{{note_label|loop_for|2|c}}{{note_label|loop_for|2|d}}{{note_label|loop_for|2|e}}{{note_label|loop_for|2|f}}{{note_label|loop_for|2|g}}{{note_label|loop_for|2|h}} C's <code>for (''init''; ''test''; ''increment'')</code> loop is a general loop construct, not specifically a counting one, although it is often used for that. # {{note label|deep_break_c|3|a}}{{note label|deep_break_c|3|b}}{{note label|deep_break_c|3|c}} Deep breaks may be accomplished in APL, C, C++ and C# through the use of labels and gotos. # {{note label|loop_phpforeach|4|a}} Iteration over objects was [http://www.php.net/manual/en/language.oop5.iterations.php added] in PHP 5. # {{note label|loop_range|5|a}}{{note label|loop_range|5|b}}{{note label|loop_range|5|c}} A counting loop can be simulated by iterating over an incrementing list or generator, for instance, Python's <code>range()</code>. # {{note label|deep_break_e|6|a}}{{note label|deep_break_e|6|b}}{{note label|deep_break_e|6|c}}{{note label|deep_break_e|6|d}}{{note label|deep_break_e|6|e}} Deep breaks may be accomplished through the use of exception handling. # {{note_label|while|7|a}} There is no special construct, since the <code>while</code> function can be used for this. # {{note_label|user|8|a}} There is no special construct, but users can define general loop functions. # {{note_label|loop_foreach|9|a}} The [[C++11]] standard introduced the [[C++11#Range-based for loop|range-based for]]. In the [[Standard Template Library|STL]], there is a <code>std::for_each</code> [[template (programming)|template]] function which can iterate on STL [[Container (data structure)|containers]] and call a [[unary function]] for each element.<ref>[http://www.sgi.com/tech/stl/for_each.html for_each]. Sgi.com. Retrieved on 2010-11-09.</ref> The functionality also can be constructed as [[C preprocessor#Macro definition and expansion|macro]] on these containers.<ref>[http://boost-sandbox.sourceforge.net/libs/foreach/doc/html/ Chapter 1. Boost.Foreach] {{Webarchive|url=https://web.archive.org/web/20100129070613/http://boost-sandbox.sourceforge.net/libs/foreach/doc/html/ |date=2010-01-29}}. Boost-sandbox.sourceforge.net (2009-12-19). Retrieved on 2010-11-09.</ref> # {{note_label|count_loop_eiffel|10|a}} Count-controlled looping is effected by iteration across an integer interval; early exit by including an additional condition for exit. # {{note_label|retry_in_eiffel|11|a}} Eiffel supports a reserved word <code>retry</code>, however it is used in [[Exception handling#Exception handling based on design by contract|exception handling]], not loop control. # {{note_label|requires_JML|12|a}} Requires [[Java Modeling Language]] (JML) behavioral interface specification language. # {{note_label|integer_variant|13|a}} Requires loop variants to be integers; transfinite variants are not supported. [http://archive.eiffel.com/doc/faq/variant.html] # {{note_label|DInfinite|13|a}} D supports infinite collections, and the ability to iterate over those collections. This does not require any special construct. # {{note_label|cobol_deep_exit|14|a}} Deep breaks can be achieved using <code>GO TO</code> and procedures. # {{note_label|cl_sequence_type|14|a}} Common Lisp predates the concept of generic collection type.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)