Expression-oriented programming language
Term orientation (of English expression-oriented ) is a property of some programming languages or a paradigm for the design of the same. Languages with this property are characterized by the fact that almost every construction results in a valid expression , which mutatis mutandis therefore also has a return value. Typical exceptions to this principle are macro definitions , preprocessor commands and declarations, which expression-oriented languages often treat as instructions and not as expressions. In some expression-oriented programming languages there is a return value of the type void . Expressions resulting from these are then only used because of their side effects .
Examples of expression-oriented programming languages are Algol 68 and Lisp , while Pascal , for example, is not an expression-oriented language. All functional programming languages are also expression-oriented.
criticism
Some language designers attribute a whole class of programming errors to Expression Orientation , especially those where a programmer confuses an assignment with the test for equality or makes it confusable. The cited source gives as an example:
if ( c++ = d++ )
…
and states as the correct alternative:
if ( ( c++ = d++ ) != 0 )
…
In Ada and Java expressions are restricted in control structures to those of this, the Boolean return values have.
In contrast, Python uses an alternative strategy: assignments are in the form of statements, not expressions. This prevents assignments within other statements or expressions.