Content deleted Content added
m stub to compu-lang-stub |
rewrite, -stub, +cat |
||
Line 1:
An '''expression-oriented programming language''' is a [[programming language]]
[[ALGOL 68]] is an example of an expression-oriented language. [[Pascal
Expression-orientation can be confusing in [[imperative programming language]]s, as many commands used normally as statements are in fact expressions. For example, assignment in the [[C programming language]] is an expression, not a statement. This allows for the following confusion:
if (x = 1) {
...
} else {
/* this branch is never executed */
}
The condition of the '''if''' is the result of the expression <code>x = 1</code>, which is 1. Thus the if will always execute the true branch. The above is often confused with:
if (x == 1) {
... /* executed if x is 1 */
} else {
... /* executed if x is not 1 */
}
For this reason, many programmers write the constant first in conditionals, as <code>1 = x</code> is a [[syntax error]], and mistyping = for == will not result in a bug.
[[Category:Programming languages]]
|