Flow-control structures: Difference between revisions
Content added Content deleted
m (Changed over to works with template) |
|||
Line 39: | Line 39: | ||
=={{header|C++}}== |
=={{header|C++}}== |
||
=== goto === |
=== goto === |
||
{{works with|GCC|3.3.4}} |
|||
#include <iostream> |
#include <iostream> |
||
Line 52: | Line 52: | ||
=== Exceptions === |
=== Exceptions === |
||
{{works with|GCC|4.0.2}} |
|||
Exceptions are a way to give control back to a direct or indirect caller in case of an error. Note that throwing exceptions is usually very expensive, therefore they generally should only be used for exceptional situations. |
Exceptions are a way to give control back to a direct or indirect caller in case of an error. Note that throwing exceptions is usually very expensive, therefore they generally should only be used for exceptional situations. |
||
Line 183: | Line 183: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{works with|Perl|5.x}} |
|||
===goto=== |
===goto=== |
||
Line 439: | Line 439: | ||
===The "with" statement=== |
===The "with" statement=== |
||
{{works with|Python|2.6}} |
|||
See [[http://www.python.org/peps/pep-0343.html PEP 0343, The "with" statement]] |
See [[http://www.python.org/peps/pep-0343.html PEP 0343, The "with" statement]] |
||
>>> with open("some_file"): # file ``some_file`` is closed after ``with`` block in any case whether an exception is raised or not |
>>> with open("some_file"): # file ``some_file`` is closed after ``with`` block in any case whether an exception is raised or not |
||
... raise Exception("an error") |
... raise Exception("an error") |
||
===Yield expressions=== |
===Yield expressions=== |
||
{{works with|Python|2.5}} |
|||
See [[http://www.python.org/peps/pep-0342.html PEP 0342, Coroutines via Enhanced Generators]] |
See [[http://www.python.org/peps/pep-0342.html PEP 0342, Coroutines via Enhanced Generators]] |
||
>>> value = 1 |
>>> value = 1 |