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!
==Notation== {{see also|Comparison of programming languages (variable and constant declarations)}} The two most common representations for the copying assignment are [[equals sign]] (<code>=</code>) and colon-equals (<code>:=</code>). Both forms may semantically denote either an assignment ''statement'' or an assignment ''[[operator (programming)|operator]]'' (which also has a value), depending on language and/or usage. :{| class="wikitable" |- | <code>''variable'' = ''expression''</code> || [[Fortran]], [[PL/I]], [[C (programming language)|C]] (and [[:Category:C programming language family|descendants]] such as [[C++]], [[Java (programming language)|Java]], etc.), [[Bourne shell]], [[Python (programming language)|Python]], [[Go (programming language)|Go]] (assignment to pre-declared variables), [[R (programming language)|R]], [[PowerShell]], [[Nim (programming language)|Nim]], etc. |- | <code>''variable'' := ''expression''</code> || [[ALGOL]] (and derivatives), [[Simula]], [[CPL (programming language)|CPL]], [[BCPL]], [[Pascal (programming language)|Pascal]]<ref name=pascal>{{cite book |last=Moore |first=Lawrie |year=1980 |title=Foundations of Programming with Pascal |location=New York |publisher=John Wiley & Sons |isbn=0-470-26939-1}}</ref> (and descendants such as [[Modula]]), [[Mary (programming language)|Mary]], [[PL/M]], [[Ada (programming language)|Ada]], [[Smalltalk]], [[Eiffel (programming language)|Eiffel]],<ref name=eiffel1>{{cite book |last=Meyer |first=Bertrand |author-link=Bertrand Meyer |year=1992 |title=Eiffel the Language |location=Hemel Hempstead |publisher=Prentice Hall International(UK) |isbn=0-13-247925-7}}</ref><ref name=eiffel2>{{cite book |last=Wiener |first=Richard |year=1996 |title=An Object-Oriented Introduction to Computer Science Using Eiffel |location=Upper Saddle River, New Jersey |publisher=Prentice Hall |isbn=0-13-183872-5}}</ref> [[Oberon (programming language)|Oberon]], [[Dylan (programming language)|Dylan]],<ref name=dylan>{{cite book |last=Feinberg |first=Neal |author2=Keene, Sonya E.|author3= Mathews, Robert O.|author4= Withington, P. Tucker |year=1997 |title=Dylan Programming |location=Massachusetts |publisher=Addison Wesley |isbn=0-201-47976-1}}</ref> [[Seed7]], [[Python (programming language)|Python]] (an assignment expression),<ref>{{cite web|url=https://www.python.org/dev/peps/pep-0572/|title=PEP 572 – Assignment Expressions|date=28 February 2018|website=python.org|access-date=4 March 2020}}</ref> [[Go (programming language)|Go]] (shorthand for declaring and defining a variable),<ref>{{cite web|url=http://golang.org/ref/spec#Short_variable_declarations|title=The Go Programming Language Specification - The Go Programming Language|website=golang.org|access-date=20 April 2018}}</ref> [[Io (programming language)|Io]], [[AMPL]], [[ML (programming language)|ML]] (assigning to a reference value),<ref name="ml">{{cite book |last=Ullman |first=Jeffrey D. |year=1998 |title=Elements of ML Programming: ML97 Edition |location=Englewood Cliffs, New Jersey |publisher=Prentice Hall |isbn=0-13-790387-1}}</ref> [[AutoHotkey]] etc. |- |} Other possibilities include a left arrow or a keyword, though there are other, rarer, variants: :{| class="wikitable" |- | <code>''variable'' << ''expression''</code> || [[Magik (programming language)|Magik]] |- | <code>''variable'' <- ''expression''</code> || [[F Sharp (programming language)|F#]], [[OCaml]], [[R (programming language)|R]], [[S (programming language)|S]] |- | <code>''variable'' <<- ''expression''</code> || [[R (programming language)|R]] |- | <code> assign("''variable''", ''expression'')</code> || [[R (programming language)|R]] |- | <code>''variable'' β ''expression''</code> || [[APL (programming language)|APL]],<ref name="aplbook">{{cite book |last=Iverson |first=Kenneth E. |author-link=Kenneth E. Iverson |title=A Programming Language |publisher=John Wiley and Sons |year=1962 |isbn=0-471-43014-5 |url=http://www.softwarepreservation.org/projects/apl/book/APROGRAMMING%20LANGUAGE/view |access-date=2010-05-09 |archive-url=https://web.archive.org/web/20090604091725/http://www.softwarepreservation.org/projects/apl/book/APROGRAMMING%20LANGUAGE/view |archive-date=2009-06-04 |url-status=dead }}</ref> [[Smalltalk]], [[BASIC Programming|Atari 2600 BASIC Programming]] |- | <code>''variable'' =: ''expression''</code> || [[J (programming language)|J]] |- | <code>LET ''variable'' = ''expression''</code> || [[BASIC]] |- | <code>let ''variable'' := ''expression''</code> || [[XQuery]] |- | <code>set ''variable'' to ''expression''</code> || [[AppleScript]] |- | <code>set ''variable'' = ''expression''</code> || [[C shell]] |- | <code>Set-Variable ''variable'' ''(expression)''</code> || [[PowerShell]] |- | <code>''variable'' : ''expression''</code> || [[Macsyma|Macsyma, Maxima]], [[K (programming language)|K]] |- | <code>''variable'': ''expression''</code> || [[Rebol]] |- | <code>var ''variable'' ''expression''</code> || [[mIRC scripting language]] |- | <code>''reference-variable'' :- ''reference-expression''</code> || [[Simula]] |} Mathematical [[pseudocode#Common mathematical symbols|pseudo code]] assignments are generally depicted with a left-arrow. Some platforms put the expression on the left and the variable on the right: :{| class="wikitable" |- | style="padding-right: 1em" | <code>MOVE ''expression'' TO ''variable''</code> || [[COBOL]] |- | style="padding-right: 1em" | <code>''expression'' β ''variable''</code> || [[TI-BASIC]], [[Casio BASIC]] |- | style="padding-right: 1em" | <code>''expression'' -> ''variable''</code> || [[POP-2]], [[BETA (programming language)|BETA]], [[R (programming language)|R]] |- | style="padding-right: 1em" | <code>put ''expression'' into ''variable''</code> || [[HyperTalk]], [[LiveCode]] |- | style="padding-right: 1em" | <code>PUT ''expression'' IN ''variable''</code> || [[ABC (programming language)|ABC]] |} Some expression-oriented languages, such as [[Lisp (programming language)|Lisp]]<ref name="clisp">{{cite book |last=Graham |first=Paul |author-link=Paul Graham (computer programmer) |year=1996 |title=ANSI Common Lisp |location=New Jersey |publisher=Prentice Hall |isbn=0-13-370875-6 |url=https://archive.org/details/ansicommonlisp00grah }}</ref><ref name="cmlisp">{{cite book |last=Steele |first=Guy L. |author-link= Guy L. Steele, Jr. |year=1990 |title=Common Lisp: The Language |location=Lexington |publisher=Digital Press |isbn=1-55558-041-6}}</ref> and Tcl, uniformly use prefix (or postfix) syntax for all statements, including assignment. :{| class="wikitable" |- | style="padding-right: 1em" | <code>(setf ''variable'' ''expression'')</code> || [[Common Lisp]] |- | <code>(set! ''variable'' ''expression'')</code> || [[Scheme (programming language)|Scheme]]<ref name="scheme">{{cite book |last=Dybvig |first=R. Kent |year=1996 |title=The Scheme Programming Language: ANSI Scheme |location=New Jersey |publisher=Prentice Hall |isbn=0-13-454646-6}}</ref><ref name="schemeint">{{cite book |last=Smith |first=Jerry D. |year=1988 |title=Introduction to Scheme |location=New Jersey |publisher=Prentice Hall |isbn=0-13-496712-7}}</ref><ref name="sussman">{{cite book |last=Abelson |first=Harold |author2=Sussman, Gerald Jay|author3= Sussman, Julie |year=1996 |title=Structure and Interpretation of Computer Programs |location=New Jersey |publisher=McGraw-Hill |isbn=0-07-000484-6}}</ref> |- | <code>set ''variable'' ''expression''</code> || [[Tcl]] |- | style="padding-right: 1em" | <code>''expression'' ''variable'' !</code> || [[Forth (programming language)|Forth]] |}
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)