Expression-oriented programming language: Difference between revisions
m Open access bot: doi added to citation with #oabot. |
Citation bot (talk | contribs) Removed proxy/dead URL that duplicated identifier. | Use this bot. Report bugs. | Suggested by Corvus florensis | #UCB_webform 1709/3499 |
||
Line 4: | Line 4: | ||
An '''expression-oriented programming language''' is a [[programming language]] in which every (or nearly every) construction is an [[expression (computer science)|expression]] and thus yields a value.<ref>{{Cite web |title=Glossary - The Rust Programming Language |url=https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/glossary.html#expression-oriented-language |access-date=2022-07-06 |website=web.mit.edu}}</ref> The typical exceptions are [[macro (computer science)|macro]] definitions, [[preprocessor]] commands, and [[declaration (computer programming)|declarations]], which expression-oriented languages often treat as [[statement (computer science)|statements]]. |
An '''expression-oriented programming language''' is a [[programming language]] in which every (or nearly every) construction is an [[expression (computer science)|expression]] and thus yields a value.<ref>{{Cite web |title=Glossary - The Rust Programming Language |url=https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/glossary.html#expression-oriented-language |access-date=2022-07-06 |website=web.mit.edu}}</ref> The typical exceptions are [[macro (computer science)|macro]] definitions, [[preprocessor]] commands, and [[declaration (computer programming)|declarations]], which expression-oriented languages often treat as [[statement (computer science)|statements]]. |
||
[[Lisp (programming language)|Lisp]]<ref name=":0">{{Cite journal |last=Syme |first=Don |date=2020-06-14 |title=The early history of F# |
[[Lisp (programming language)|Lisp]]<ref name=":0">{{Cite journal |last=Syme |first=Don |date=2020-06-14 |title=The early history of F# |journal=Proceedings of the ACM on Programming Languages |language=en |volume=4 |issue=HOPL |pages=1–58 |doi=10.1145/3386325 |issn=2475-1421|doi-access=free }}</ref> and [[ALGOL 68]] are expression-oriented languages. [[Pascal programming language|Pascal]] is not an expression-oriented language. |
||
All [[functional programming language]]s are expression-oriented.{{citation needed|date=September 2020}} |
All [[functional programming language]]s are expression-oriented.{{citation needed|date=September 2020}} |
Revision as of 22:44, 16 February 2023
![]() | The topic of this article may not meet Wikipedia's general notability guideline. (July 2022) |
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.[citation needed]
Criticism and prevention
![]() | This article or section possibly contains original synthesis. Source material should verifiably mention and relate to the main topic. (July 2022) |
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.
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.[4][5]
The designers of Python implemented 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
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
- ^ "Glossary - The Rust Programming Language". web.mit.edu. Retrieved 2022-07-06.
- ^ 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.
- ^ Java Code Conventions "10.4 Variable Assignments"
- ^ The Java Language Specification, Java SE 8 Edition "14.9 The if Statement"
- ^ Introducing Ada
- ^ The Python Language Reference "6.2. Assignment statements"
- ^ "PEP 572: Assignment Expressions"
- ^ "Functions - The Rust Programming Language". web.mit.edu. Retrieved 2022-07-06.
- ^ "COS 326: Functional Programming". www.cs.princeton.edu. Retrieved 2022-07-06.