Expression-oriented programming language

From Wikipedia, the free encyclopedia

Page Module:Message box/ambox.css has no content.

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.

Lisp[2] and ALGOL 68 are expression-oriented languages. Pascal is not an expression-oriented language.

All functional programming languages are expression-oriented.

Criticism and prevention

Page Module:Message box/ambox.css has no content.

Script error: No such module "Labelled list hatnote". Critics, including language designers,[3][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.

Some languages such as Ada and Java prevent this type of mistake by restricting control expressions to those that evaluate strictly to the boolean data type.[4][5]

Some languages such as Python implement assignment as a statement rather than an expression, thus prohibiting assignment from nesting inside any other statement or expression.[6] (Until version 3.8 added 'assignment expressions', with a different syntax.[7])

In some expression-oriented languages, expressions that merely cause side effects return void types.

Examples

Page Module:Message box/ambox.css has no content.

Page Module:Message box/ambox.css has no content.

See also

References

Page Template:Reflist/styles.css has no content.

  1. ^ Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  2. ^ a b Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  3. ^ Java Code Conventions "10.4 Variable Assignments"
  4. ^ The Java Language Specification, Java SE 8 Edition "14.9 The if Statement"
  5. ^ Introducing Ada
  6. ^ The Python Language Reference "6.2. Assignment statements"
  7. ^ "PEP 572: Assignment Expressions"
  8. ^ Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  9. ^ Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.

Template:Programming paradigms navbox