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

edit

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

edit

See also

edit

References

edit
  1. ^ "Glossary - The Rust Programming Language". web.mit.edu. Retrieved 2022-07-06.
  2. ^ a b Syme, Don (2020-06-14). "The early history of F#". Proceedings of the ACM on Programming Languages. 4 (HOPL): 1–58. doi:10.1145/3386325. ISSN 2475-1421.
  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. ^ "Functions - The Rust Programming Language". web.mit.edu. Retrieved 2022-07-06.
  9. ^ "COS 326: Functional Programming". www.cs.princeton.edu. Retrieved 2022-07-06.

📚 Artikel Terkait di Wikipedia

SNOBOL

SNOBOL (StriNg Oriented and symBOlic Language) is a series of programming languages developed between 1962 and 1967 at AT&T Bell Laboratories by David

F Sharp (programming language)

strongly typed, multi-paradigm programming language that encompasses functional, imperative, and object-oriented programming methods. It is most often used

List of programming languages by type

dynamic programming language ) Prograph (dataflow, object-oriented (class-based), visual) Python (functional, compiled, interpreted, object-oriented (class-based)

Stack-oriented programming

constructs in other programming languages need to be modified for use in a stack-oriented system. Most stack-oriented languages operate in postfix or

Domain-specific language

domain-specific language is somewhere between a tiny programming language and a scripting language, and is often used in a way analogous to a programming library

Expression problem

The expression problem is a problem in programming languages that concerns the extensibility and modularity of statically typed data abstractions. The

Aspect-oriented programming

In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting

High-level programming language

allowing object-oriented and generic programming while retaining systems-programming capabilities. Scripting and rapid-application languages such as Perl