Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Control flow
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
== Control structures in practice == Most programming languages with control structures have an initial keyword which indicates the type of control structure involved.{{clarify|date=November 2015}} Languages then divide as to whether or not control structures have a final keyword. * No final keyword: [[ALGOL 60]], [[C (programming language)|C]], [[C++]], [[Go (programming language)|Go]], [[Haskell]], [[Java (programming language)|Java]], [[Pascal (programming language)|Pascal]], [[Perl]], [[PHP]], [[PL/I]], [[Python (programming language)|Python]], [[PowerShell]]. Such languages need some way of grouping statements together: ** ALGOL 60 and Pascal: <code>begin</code> ... <code>end</code> ** C, C++, Go, Java, Perl, PHP, and PowerShell: [[Curly bracket programming language|curly brackets]] <code>{</code> ... <code>}</code> ** PL/I: <code>DO</code> ... <code>END</code> ** Python: uses [[Indent style|indent]] level (see [[Off-side rule]]) ** Haskell: either [[Indent style|indent]] level or curly brackets can be used, and they can be freely mixed ** Lua: uses <code>do</code> ... <code>end</code> * Final keyword: [[Ada (programming language)|Ada]], [[APL (programming language)|APL]], [[ALGOL 68]], [[Modula-2]], [[Fortran 77]], [[Mythryl]], [[Visual Basic]]. The forms of the final keyword vary: ** Ada: final keyword is <code>end</code> + ''space'' + initial keyword e.g., <code>if</code> ... <code>end if</code>, <code>loop</code> ... <code>end loop</code> ** APL: final keyword is <code>:End</code> optionally + initial keyword, e.g., <code>:If</code> ... <code>:End</code> or <code>:If</code> ... <code>:EndIf</code>, <code>Select</code> ... <code>:End</code> or <code>:Select</code> ... <code>:EndSelect</code>, however, if adding an end condition, the end keyword becomes <code>:Until</code> ** ALGOL 68, Mythryl: initial keyword spelled backwards e.g., <code>if</code> ... <code>fi</code>, <code>case</code> ... <code>esac</code> ** Fortran 77: final keyword is <code>END</code> + initial keyword e.g., <code>IF</code> ... <code>ENDIF</code>, <code>DO</code> ... <code>ENDDO</code> ** Modula-2: same final keyword <code>END</code> for everything ** Visual Basic: every control structure has its own keyword. <code>If</code> ... <code>End If</code>; <code>For</code> ... <code>Next</code>; <code>Do</code> ... <code>Loop</code>; <code>While</code> ... <code>Wend</code>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Control flow
(section)
Add topic