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
Pascal (programming language)
(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!
===Semicolons as statement separators=== Pascal adopted many language syntax features from the [[ALGOL]] language, including the use of a semicolon as a statement separator. This is in contrast to other languages, such as [[PL/I]] and [[C (programming language)|C]], which use the semicolon as a statement terminator. No semicolon is needed before the <code>end</code> keyword of a record type declaration, a block, or a ''case'' statement; before the <code>until</code> keyword of a repeat statement; and before the <code>else</code> keyword of an ''if'' statement. The presence of an extra semicolon was not permitted in early versions of Pascal. However, the addition of [[ALGOL]]-like empty statements in the 1973 ''Revised Report'' and later changes to the language in ISO 7185:1983 now allow for optional semicolons in most of these cases. A semicolon is still not permitted immediately before the <code>else</code> keyword in an ''if'' statement, because the <code>else</code> follows a single statement, not a statement sequence. In the case of nested ifs, a semicolon cannot be used to avoid the [[dangling else]] problem (where the inner if does not have an else, but the outer if does) by putatively terminating the nested if with a semicolon β this instead terminates both if clauses. Instead, an explicit <code>begin</code>...<code>end</code> block must be used.<ref>''Pascal,'' Nell Dale and Chip Weems, "Dangling Else", [https://books.google.com/books?id=5x2k4vWwn1wC&pg=PA160 p. 160β161] {{webarchive|url=https://web.archive.org/web/20170318223956/https://books.google.com/books?id=5x2k4vWwn1wC&pg=PA160 |date=2017-03-18}}</ref>
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)