An expression-oriented programming language is a programming language in which every (or nearly every) construction is an expression and thus yields a value.[1] The typical exceptions are macro definitions, preprocessor commands, and declarations, which expression-oriented languages often treat as statements.
The topic of this article may not meet Wikipedia's general notability guideline. (July 2022) |
Lisp[2] and ALGOL 68 are expression-oriented languages. Pascal is not an expression-oriented language.
All functional programming languages are expression-oriented.[3]
Criticism and prevention
This article or section possibly contains synthesis of material which does not verifiably mention or relate to the main topic. (July 2022) |
Critics, including language designers,[4][failed verification] blame expression-orientation for an entire class of programming mistakes wherein a programmer accidentally codes an assignment expression, which replaces a variable with an expression rather than testing it for equality with that expression.
The designers of Ada and Java prevent this type of mistake by restricting control expressions to those that evaluate strictly to the boolean data type.[5][6]
The designers of Python implemented assignment as a statement rather than an expression, thus prohibiting assignment from nesting inside any other statement or expression.[7] (Until version 3.8 added 'assignment expressions', with a different syntax.[8])
In some expression-oriented languages, expressions that merely cause side effects return void types.
Examples
This article needs additional citations for verification. (July 2022) |
This section needs expansion. You can help by adding to it. (February 2018) |
See also
References
Wikiwand in your browser!
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.