Comparison of programming languages (basic instructions): Difference between revisions

Content deleted Content added
Reorganize remaining apostrophes (as much as I care to for the time being)
m Fix lint errors
Line 1,816:
| rowspan=7| <code>if (''condition'') ''instructions''<br />«else ''instructions''»</code><br />{{code|instructions}} can be a single statement or a block in the form of: <code>{ ''statements'' }</code>
| rowspan=7| <code>if (''condition'') ''instructions''<br />else if (''condition'') ''instructions''<br />''...''<br />«else ''instructions»''</code><br />or<br /><code>if (''condition'') ''instructions''<br />else { if (''condition'') ''instructions'' }</code>
| rowspan=7| <code>switch (''variable'') { {{indent|2}}case ''case1'': ''instructions'' «; break;»{{indent|2}}''...''{{indent|2}}«default: ''instructions''»<br />}</code>
| rowspan=7| <code>''condition'' [[?:|?]] ''valueIfTrue'' [[?:|:]] ''valueIfFalse''</code>
|- valign="top"
Line 1,835:
{{code|instructions}} can be a single statement or a block in the form of: <code>{ ''statements'' }</code>
| <code>if (''condition'') ''instructions''<br />else if (''condition'') ''instructions''<br />''...''<br />«else ''instructions''»</code>
| <code>switch (''variable'')<br />{ {{indent|2}}case ''case{{sub|1}}'':{{indent|4}}''instructions''{{indent|4}}«''break_or_jump_statement''»{{indent|2}}''...''{{indent|2}}«default:{{indent|4}}''instructions''{{indent|4}}''break_or_jump_statement''»<br />}</code>
All non-empty cases must end with a {{code|break}} or {{code|goto case}} statement (that is, they are not allowed to fall-through to the next case).
The {{code|default}} case is not required to come last.
Line 1,855:
| <code>if ''condition'' {''instructions''}<br />«else {''instructions''}»</code>
| <code>if ''condition'' {''instructions''}<br />else if ''condition'' {''instructions''}<br />''...''<br />«else {''instructions''}»</code>
| <code>switch ''variable'' { {{indent|2}}case ''case<sub>1</sub>'': ''instructions''{{indent|2}}''...''{{indent|2}}«default: ''instructions''»<br />}</code>
|
|- valign="top"
Line 1,867:
| <code>if ''condition'' {''instructions''}<br />«else {''instructions''}»</code><br />or<br /><code>unless ''notcondition'' {''instructions''}</code>
| <code>if ''condition'' {''instructions''} <br />elsif ''condition'' {''instructions''} <br />...<br />«else {''instructions''}</code>
| <code>given ''variable'' { {{indent|2}}when ''case<sub>1</sub>'' { ''instructions'' }{{indent|2}}''...''{{indent|2}}«default { ''instructions'' }»<br />}</code>
| <code>''condition'' [[?:|??]] ''valueIfTrue'' !! ''valueIfFalse''</code>
|- valign="top"
Line 1,879:
| <code>if (''condition'') {''instructions''}<br />«else {''instructions''}»</code>
| <code>if (''condition'') {''instructions''}<br />else if (''condition'') {''instructions''}<br />...<br />«else {''instructions''}»</code>
| <code>''expression'' match { {{indent|2}}case ''pattern1'' => ''expression''{{indent|2}}case ''pattern2'' => ''expression''{{indent|2}}''...''{{indent|2}}«case _ => ''expression''»<br />}</code>{{ref|pattern matching|[b]}}
| <code>if (''condition'') ''valueIfTrue'' else ''valueIfFalse''</code>
|- valign="top"
Line 1,966:
| <code>if ''condition'' then ''expression'' else ''expression''</code><br />or<br /><code>when ''condition'' (do ''instructions'')</code><br />or<br /><code>unless ''notcondition'' (do ''instructions'')</code>
| <code>''result'' {{pipe}} ''condition'' = ''expression''{{indent|2}}{{pipe}} ''condition'' = ''expression''{{indent|2}}{{pipe}} otherwise = ''expression''</code>
| <code>case ''value'' of { {indent|2}}''pattern1'' -> ''expression'';{{indent|2}}''pattern2'' -> ''expression'';{{indent|2}}''...''{{indent|2}}«_ -> ''expression»''<br />}</code>{{ref|pattern matching|[b]}}
|- valign="top"
| [[Bash shell]]
Line 2,396:
| [[Haskell (programming language)|Haskell]] ([[Glasgow Haskell Compiler|GHC]])
| <code>throw ''exception''</code><br />or<br /><code>throwError ''expression''</code>
| <code>catch ''tryExpression catchExpression''</code><br />or<br /><code>catchError ''tryExpression catchExpression''</code>
| <code>assert ''condition expression''</code>
|-
Line 2,631:
| <code>foo''«(parameters)»;''</code>
| <code>proc foo ''= «(parameters)»'' [[void type|void]]: ( ''instructions'' );</code>
| <code>proc foo ''= «(parameters)»'' rettype'': ( ''instructions ...; retvalue'' );</code>
| {{n/a}}
|- valign="top"
Line 2,964:
| <code>''integer'' = CInt(''string'')</code>
| <code>''long'' = CLng(''string'')</code>
| <code>''float'' = CSng(''string'')<br />;;''double'' = CDbl(''string'')</code>
| <code>''string'' = CStr(''number'')</code>
|