Flow-control structures: Difference between revisions

Content added Content deleted
m (Changed over to works with template)
Line 39:
=={{header|C++}}==
=== goto ===
'''Compiler:'''{{works [[with|GCC]] |3.3.4}}
#include <iostream>
Line 52:
 
=== Exceptions ===
'''Compiler:'''{{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.
Line 183:
 
=={{header|Perl}}==
'''Interpreter:'''{{works [[with|Perl]] |5.x}}
 
===goto===
Line 439:
 
===The "with" statement===
'''Interpreter:'''{{works [[with|Python]] |2.6}}
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
... raise Exception("an error")
===Yield expressions===
'''Interpreter:'''{{works [[with|Python]] |2.5}}
See [[http://www.python.org/peps/pep-0342.html PEP 0342, Coroutines via Enhanced Generators]]
>>> value = 1