Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Assignment (computer science)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Setting or re-setting the value associated with a variable name}} {{for|assignment of letters to disk file systems|Drive letter assignment}} In [[computer programming]], an '''assignment statement''' sets and/or re-sets the [[value (computer science)|value]] stored in the storage location(s) denoted by a [[variable (programming)|variable]] [[name]]; in other words, it copies a value into the variable. In most [[imperative programming|imperative]] [[programming language]]s, the assignment statement (or expression) is a fundamental construct. Today, the most commonly used notation for this operation is <code>''x'' = ''expr''</code> (originally [[Superplan]] 1949β51, popularized by [[Fortran]] 1957 and [[C (programming language)|C]]). The second most commonly used notation is<ref name="2CS24" /> <code>''x'' := ''expr''</code> (originally [[ALGOL]] 1958, popularised by [[Pascal (programming language)|Pascal]]).<ref name="weisskop">{{cite web|url=http://www.cs.uah.edu/~weisskop/Notes424-524/ch12.ppt|title=Imperative Programming|website=uah.edu|access-date=20 April 2018|archive-date=4 March 2016|archive-url=https://web.archive.org/web/20160304035233/http://www.cs.uah.edu/~weisskop/Notes424-524/ch12.ppt|url-status=dead}}</ref> Many other notations are also in use. In some languages, the symbol used is regarded as an [[operator (programming)|operator]] (meaning that the assignment statement as a whole returns a value). Other languages define assignment as a statement (meaning that it cannot be used in an expression). Assignments typically allow a variable to hold different values at different times during its life-span and [[scope (programming)|scope]]. However, some languages (primarily [[Functional programming|strictly functional]] languages) do not allow that kind of "destructive" reassignment, as it might imply changes of non-local state. The purpose is to enforce [[referential transparency]], i.e. functions that do not depend on the state of some variable(s), but produce the same results for a given set of parametric inputs at any point in time. Modern programs in other languages also often use similar strategies, although less strict, and only in certain parts, in order to reduce complexity, normally in conjunction with complementing methodologies such as [[data structures|data structuring]], [[structured programming]] and [[object-oriented programming|object orientation]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)