Knowledge

Assignment (computer science)

Source 📝

125:, 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 1411:" was intended. This is a common programming problem with languages such as C (including one famous attempt to backdoor the Linux kernel), where the assignment operator also returns the value assigned (in the same way that a function returns a value), and can be validly nested inside expressions. If the intention was to compare two values in an 363:
if it does not change an observable state of the machine, other than producing the result, and always produces same value for the same input. Imperative assignment can introduce side effects while destroying and making the old value unavailable while substituting it with a new one, and is referred to
496:
single-assignment, explicit in a sense that its (named) variables can be in explicitly unassigned state, or be set exactly once. In Haskell, by contrast, there can be no unassigned variables, and every variable can be thought of as being implicitly set, when it is created, to its value (or rather to
683:
Not all programming languages support chained assignment. Chained assignments are equivalent to a sequence of assignments, but the evaluation strategy differs between languages. For simple chained assignments, like initializing multiple variables, the evaluation strategy does not matter, but if the
1301:
A notorious example for a bad idea was the choice of the equal sign to denote assignment. It goes back to Fortran in 1957 and has blindly been copied by armies of language designers. Why is it a bad idea? Because it overthrows a century old tradition to let “=” denote a comparison for equality, a
1302:
predicate which is either true or false. But Fortran made it to mean assignment, the enforcing of equality. In this case, the operands are on unequal footing: The left operand (a variable) is to be made equal to the right operand (an expression). x = y does not mean the same thing as y = x.
1288:
as an assignment operator has been frequently criticized, due to the conflict with equals as comparison for equality. This results both in confusion by novices in writing code, and confusion even by experienced programmers in reading code. The use of equals for assignment dates back to
149:
in which different values are associated with a particular variable name as time passes. The program, in such model, operates by changing its state using successive assignment statements. Primitives of imperative programming languages rely on assignment to do
406:
Impure functional languages provide both single assignment as well as true assignment (though true assignment is typically used with less frequency than in imperative programming languages). For example, in Scheme, both single assignment (with
172:
are containers for values. It is possible to put a value into a variable and later replace it with a new one. An assignment operation modifies the current state of the executing program. Consequently, assignment is dependent on the concept of
714:, assignment statements are not expressions and thus do not have a value. Instead, chained assignments are a series of statements with multiple targets for a single expression. The assignments are executed left-to-right so that 321:
ones, it is not necessary to declare a variable prior to assigning it a value. In such languages, a variable is automatically declared the first time it is assigned to, with the scope it is declared in varying by language.
2759:, "Finally, Go has no comma operator and ++ and -- are statements not expressions. Thus if you want to run multiple variables in a for you should use parallel assignment (although that precludes ++ and --)." 828:, though this is confusing when used with "single assignment", as these are not opposites. If the right-hand side of the assignment is a single variable (e.g. an array or structure), the feature is called 415:) can be used on all variables, and specialized primitives are provided for destructive update inside lists, vectors, strings, etc. In OCaml, only single assignment is allowed for variables, via the 1337:) is used for both the assignment operator and the equality relational operator, with context determining which is meant. Other languages use different symbols for the two operators. For example: 1432: 609:
to reduce redundancy in the source code, but also assists readers of the code in understanding the programmer's intent, and provides the compiler with a clue to possible optimization.
1326:
in mathematics, and is used for assignment in many languages. But assignment alters the value of a variable, while equality testing tests whether two expressions have the same value.
387:, which do not have variables in the sense of imperative programming languages but rather named constant values possibly of compound nature, with their elements progressively defined 1262:, and is replaced by parallel assignment in other languages such as Go. However, the above C++ code does not ensure perfect simultaneity, since the right side of the following code 589:, there is no variable assignment; but operations similar to assignment (like assigning to a field of an array or a field of a mutable data structure) usually evaluate to the 356:
and differs from assignment as described in this article in that it can only be done once, usually when the variable is created; no subsequent reassignment is allowed.
110:(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). 597:. This type has only one possible value, therefore containing no information. It is typically the type of an expression that is evaluated purely for its side effects. 691:
for example), chained assignments are supported because assignments are expressions, and have values. In this case chain assignment can be implemented by having a
3076: 278:
is first declared as an int, and is then assigned the value of 10. Notice that the declaration and assignment occur in the same statement. In the second line,
2387: 1168:
method on the expression, which must have output parameters for the variables being assigned to. For example, one such method that would give the
2218: 2333: 692: 121:
languages) do not allow that kind of "destructive" reassignment, as it might imply changes of non-local state. The purpose is to enforce
2702: 513: 2253: 908: 3251: 1490: 2434: 2364: 2299: 1279: 2665: 643:. Beyond syntactic sugar, this assists the task of the compiler by making clear that in-place modification of the variable 17: 1415:
statement, for instance, an assignment is quite likely to return a value interpretable as Boolean true, in which case the
707:
they are also available for values of class types by declaring the appropriate return type for the assignment operator.
623:
The case where the assigned value depends on a previous one is so common that many imperative languages, most notably
3230: 3205: 3180: 3155: 3127: 3113: 3092: 3086: 3056: 2980: 2955: 2930: 2902: 2638: 2611: 2584: 2554: 2466: 775: 1157:
with implementation defined by the expression on the right-hand side, as the compiler searches for an appropriate
3256: 2162: 1665: 1250:
is similar to parallel assignment in allowing multiple assignments to occur within a single statement, writing
958: 900: 586: 450: 446: 384: 360: 605:
Certain use patterns are very common, and thus often have special syntax to support them. These are primarily
2794: 2105: 1597: 1585: 1581: 1557: 1506: 1346: 904: 783: 711: 579: 466: 442: 341: 331: 103: 2482: 684:
targets (l-values) in the assignment are connected in some way, the evaluation strategy affects the result.
113:
Assignments typically allow a variable to hold different values at different times during its life-span and
2141: 1647: 1589: 1169: 474: 318: 2507: 2398: 575:, the return value of a function is used to control a loop while assigning that same value to a variable. 2157: 2063: 2010: 1565: 1498: 962: 791: 470: 134: 2052: 1733: 1573: 1549: 1522: 1419:
clause will be executed, leading the program to behave unexpectedly. Some language processors (such as
1147: 817: 771: 747: 867:. In languages without parallel assignment, this would have to be written to use a temporary variable 2226: 1613: 1605: 1601: 1510: 896: 755: 509:
In some programming languages, an assignment statement returns a value, while in others it does not.
462: 2779: 2014: 1940: 1875: 1759: 1715: 1695: 1677: 1673: 1514: 1486: 1376: 1361: 688: 624: 517: 383:
Single assignment is the only form of assignment available in purely functional languages, such as
314: 300: 216: 122: 85: 46: 2844: 1911: 1420: 31: 2330: 1628:
Other possibilities include a left arrow or a keyword, though there are other, rarer, variants:
2774: 1455: 1323: 1270:
will assign the two variables concurrently, using the initial value of a to compute the new b.
426:
syntax; however destructive update can be used on elements of arrays and strings with separate
400: 373: 345: 174: 169: 146: 130: 118: 107: 57: 50: 2970: 106:). Many other notations are also in use. In some languages, the symbol used is regarded as an 2727: 2424: 2354: 2289: 2066:
and Tcl, uniformly use prefix (or postfix) syntax for all statements, including assignment.
1391:
The similarity in the two symbols can lead to errors if the programmer forgets which form ("
628: 618: 60: 38: 3022: 8: 1319: 1259: 582:
for example, the return value of an assignment is undefined and such idioms are invalid.
430:
operator, as well as on fields of records and objects that have been explicitly declared
114: 2261: 403:
of sequential one step at a time execution, since values are independent of each other.
3143: 3072: 2172: 965:, shown here, require explicit tuple construction and deconstruction with parentheses: 396: 377: 434:(meaning capable of being changed after their initial declaration) by the programmer. 3226: 3201: 3176: 3151: 3123: 3082: 3052: 2976: 2951: 2926: 2898: 2634: 2628: 2607: 2601: 2580: 2550: 2462: 2430: 2360: 2295: 1741: 1290: 155: 2574: 2459:
The Haskell School of Expression: Learning Functional Programming Through Multimedia
3117: 2971:
Feinberg, Neal; Keene, Sonya E.; Mathews, Robert O.; Withington, P. Tucker (1997).
2770: 2350: 2167: 1162: 1143: 911:
to allow multiple return values from a single function, as in this Python example,
767: 445:(it accepts multiple assignment if the values are equal, in contrast to Haskell), 348:, assignment is discouraged in favor of single assignment, more commonly known as 2337: 1158: 606: 392: 126: 520:), the assignment statement returns the assigned value, allowing such idioms as 2918: 2756: 1247: 151: 2677: 1423:) can detect such situations, and warn the programmer of the potential error. 3245: 1946:
Some platforms put the expression on the left and the variable on the right:
1307: 675:. Chained assignments are often used to initialize multiple variables, as in 2996: 2752: 1502: 1297:, designed from 1949 to 1951, and was particularly popularized by Fortran: 486: 353: 196:
is assigned the computed value, replacing the prior value of that variable.
2533: 3023:"The Go Programming Language Specification - The Go Programming Language" 2086: 1988: 1816: 1438: 751: 482: 3220: 2569: 1433:
Comparison of programming languages (variable and constant declarations)
2570: 1853: 1617: 1518: 795: 759: 454: 63:, the assignment statement (or expression) is a fundamental construct. 2291:
Bioinformatics programming in Python: a practical course for beginners
798:
allow several variables to be assigned in parallel, with syntax like:
627:
and the majority of its descendants, provide special operators called
395:
languages. Purely functional languages can provide an opportunity for
1737: 1577: 1294: 590: 77: 437:
Functional programming languages that use single assignment include
2845:"Static Analyzer Options (Using the GNU Compiler Collection (GCC))" 2033: 1984: 1437:
The two most common representations for the copying assignment are
293:
For an assignment operation, it is necessary that the value of the
2820: 1871: 1835: 1478: 1150:(1974), and CLU helped popularize parallel assignment generally. 438: 431: 81: 2948:
An Object-Oriented Introduction to Computer Science Using Eiffel
2869: 1929: 1797: 1561: 1545: 1266:
is evaluated after the left side. In languages such as Python,
738:
though no actual variable is produced for the temporary value.
489: 56:; in other words, it copies a value into the variable. In most 27:
Setting or re-setting the value associated with a variable name
1459:(which also has a value), depending on language and/or usage. 1280:
Relational operator § Confusion with assignment operators
309:
represents a modifiable entity (it is a valid modifiable (non-
3221:
Abelson, Harold; Sussman, Gerald Jay; Sussman, Julie (1996).
2331:
Crossing borders: Explore functional programming with Haskell
2006: 1966: 1893: 1778: 1669: 1593: 1541: 1494: 1342: 1330: 1146:
for returning multiple values from a function. This dates to
787: 704: 478: 458: 310: 99: 66:
Today, the most commonly used notation for this operation is
1318:
Beginning programmers sometimes confuse assignment with the
1609: 1569: 1553: 1482: 1449:). Both forms may semantically denote either an assignment 1387:, but a single equals sign can be used in certain contexts. 779: 369: 53: 2123: 1368:) while the equality operator is a pair of equals signs ( 1349:, the assignment operator is a colon and an equals sign ( 763: 2195:
predates Fortran, though it was popularized by Fortran.
1172:
it appears in the same behavior as the return value of
726:, and then assigns the same result to the next target, 154:. At the lowest level, assignment is implemented using 1943:
assignments are generally depicted with a left-arrow.
282:
is declared without an assignment. In the third line,
2287: 907:, combine parallel assignment, tuples, and automatic 695:, and assignments happen right-to-left. For example, 2925:. Hemel Hempstead: Prentice Hall International(UK). 469:(for some data structures like lists, not symbols), 336:
Any assignment that changes an existing value (e.g.
30:
For assignment of letters to disk file systems, see
2483:"7. Simple statements — Python 3.6.5 documentation" 1604:(shorthand for declaring and defining a variable), 1364:, the assignment operator is a single equals sign ( 845:The list will be unpacked so that 0 is assigned to 497:a computational object that will produce its value 2630:Programming Ruby: The Pragmatic Programmer's Guide 2626: 1353:) while the equality operator is a single equals ( 722:, then assigns the result to the leftmost target, 3223:Structure and Interpretation of Computer Programs 2950:. Upper Saddle River, New Jersey: Prentice Hall. 2573:; Christiansen, Tom; Schwartz, Randal C. (1996). 212:is doubled after the execution of the statement. 187:is evaluated in the current state of the program. 3243: 2422: 3051:. Englewood Cliffs, New Jersey: Prentice Hall. 359:An evaluation of an expression does not have a 49:stored in the storage location(s) denoted by a 2429:. Cambridge University Press. pp. 81–82. 600: 2544: 2416: 1273: 88:). The second most commonly used notation is 3173:The Scheme Programming Language: ANSI Scheme 2867: 2326: 2324: 2322: 2320: 2318: 2062:Some expression-oriented languages, such as 2868:Deitel, Paul; Deitel, Harvey (2022-10-25). 2532:The Go Programming Language Specification: 2343: 2283: 2281: 2279: 1142:This provides an alternative to the use of 2359:. Cambridge University Press. p. 23. 2248: 2246: 2244: 3189: 2778: 2768: 2678:"PEP 3132 -- Extended Iterable Unpacking" 2461:. Cambridge: Cambridge University Press. 2315: 514:expression-oriented programming languages 504: 3049:Elements of ML Programming: ML97 Edition 2997:"PEP 572 – Assignment Expressions" 2388:"Imperative Programming Languages (IPL)" 2349: 2276: 1513:(assignment to pre-declared variables), 286:is reassigned the value of 23. Finally, 145:An assignment operation is a process in 3214: 3071: 3065: 2939: 2911: 2771:"Good Ideas, Through the Looking Glass" 2728:"Deconstructing tuples and other types" 2241: 2213: 2211: 1379:, the assignment operator is basically 612: 397:computation to be performed in parallel 208:means that the content of the variable 14: 3244: 3170: 3164: 3142: 3136: 3112: 3046: 2945: 2895:Foundations of Programming with Pascal 2886: 2818: 2633:. Upper Saddle River: Addison Wesley. 2593: 2450: 2380: 842:list := {0, 1} a, b := list 741: 204:is a numeric variable, the assignment 3195: 3106: 2964: 2917: 2892: 2538: 2456: 1312:Good Ideas, Through the Looking Glass 650: 465:(for dataflow variables, not cells), 352:. Single assignment is an example of 117:. However, some languages (primarily 2627:Thomas, David; Hunt, Andrew (2001). 2620: 2606:(2 ed.). Sebastopol: O´Reilly. 2599: 2563: 2208: 873:t := a a := b b := t 746:Some programming languages, such as 734:. This is essentially equivalent to 524:, in which the assignment statement 325: 2897:. New York: John Wiley & Sons. 2821:"An attempt to backdoor the kernel" 2579:(2 ed.). Cambridge: O´Reilly. 1153:C# additionally allows generalized 24: 3040: 2795:"C++ Programming Language. Basics" 1616:(assigning to a reference value), 804:which simultaneously assigns 0 to 667:is assigned to multiple variables 25: 3268: 2975:. Massachusetts: Addison Wesley. 2426:Concepts in programming languages 2356:Concepts in programming languages 441:(for data structures, not vars), 2870:"C++ Control Statements, Part 2" 1403:") is appropriate, or mistypes " 578:In other programming languages, 317:). In some languages, typically 3015: 2989: 2861: 2837: 2812: 2787: 2762: 2746: 2720: 2695: 2670: 2647: 2526: 2500: 2185: 957:while other languages, such as 687:In some programming languages ( 537: 299:is well-defined (it is a valid 290:is assigned the value of 32.4. 2657:, "The main features of CPL", 2475: 2288:Ruediger-Marcus Flaig (2008). 2163:Unification (computer science) 812:. This is most often known as 13: 1: 3252:Programming language concepts 3200:. New Jersey: Prentice Hall. 3175:. New Jersey: Prentice Hall. 3122:. New Jersey: Prentice Hall. 2549:. New Jersey: Prentice Hall. 2294:. Wiley-VCH. pp. 98–99. 2202: 1258:. This is primarily used in 736:tmp = f(); i = tmp; arr = tmp 332:Static single-assignment form 274:In this sample, the variable 3150:. Lexington: Digital Press. 1600:(an assignment expression), 693:right-associative assignment 532:, which is then assigned to 411:) and true assignment (with 140: 7: 3225:. New Jersey: McGraw-Hill. 3047:Ullman, Jeffrey D. (1998). 2603:Python Programming Language 2545:INMOS Limited, ed. (1988). 2151: 1426: 1329:In some languages, such as 1322:for equality, as "=" means 1284:The use of the equals sign 888:with the original value of 601:Variant forms of assignment 10: 3273: 2819:Corbet (6 November 2003). 2703:"Destructuring assignment" 2336:November 19, 2010, at the 1430: 1277: 1274:Assignment versus equality 970:// Valid C# or Rust syntax 824:, and is sometimes called 639:can instead be written as 616: 593:, which is represented as 329: 29: 3148:Common Lisp: The Language 2576:Perl Programming Language 2508:"CLHS: Macro SETF, PSETF" 2423:John C. Mitchell (2003). 2158:Assignment operator (C++) 1560:(and descendants such as 1155:deconstruction assignment 730:, using the new value of 718:evaluates the expression 536:. In a statement such as 3196:Smith, Jerry D. (1988). 3171:Dybvig, R. Kent (1996). 2946:Wiener, Richard (1996). 2666:full text (subscription) 2547:Occam 2 Reference Manual 2254:"Imperative Programming" 2178: 1333:, a single equals sign ( 1178: 1080: 1007: 967: 913: 895:Some languages, such as 878:a := b; b := a 834:destructuring assignment 820:in 1963, under the name 221: 123:referential transparency 80:1949–51, popularized by 45:sets and/or re-sets the 3081:. John Wiley and Sons. 1912:mIRC scripting language 822:simultaneous assignment 816:; it was introduced in 492:code can be considered 457:(for constants), Lava, 200:Example: Assuming that 32:Drive letter assignment 3198:Introduction to Scheme 3078:A Programming Language 2893:Moore, Lawrie (1980). 1316: 663:in which the value of 505:Value of an assignment 401:von Neumann bottleneck 374:functional programming 366:destructive assignment 346:functional programming 215:An example segment of 147:imperative programming 131:structured programming 3257:Assignment operations 2512:Common Lisp Hyperspec 1299: 679:a = b = c = d = f = 0 528:returns the value of 102:1958, popularised by 61:programming languages 2457:Hudak, Paul (2000). 1924:reference-expression 1445:) and colon-equals ( 1083:// Rust tuple return 859:swaps the values of 629:augmented assignment 619:Augmented assignment 613:Augmented assignment 378:destructive updating 177:. In an assignment: 43:assignment statement 39:computer programming 18:Assignment operation 3073:Iverson, Kenneth E. 2923:Eiffel the Language 2600:Lutz, Mark (2001). 2219:"2cs24 Declarative" 1544:(and derivatives), 1320:relational operator 826:multiple assignment 814:parallel assignment 742:Parallel assignment 368:for that reason in 340:) is disallowed in 119:strictly functional 3003:. 28 February 2018 2173:Assignment problem 1920:reference-variable 1246:In C and C++, the 1010:// C# tuple return 856:a, b := b, a 801:a, b := 0, 1 701:arr = f(); i = arr 661:chained assignment 651:Chained assignment 156:machine operations 135:object orientation 2973:Dylan Programming 2682:legacy.python.org 2436:978-0-521-78098-8 2366:978-0-521-78098-8 2351:Mitchell, John C. 2301:978-3-527-32094-3 2223:www.csc.liv.ac.uk 2147: 2146: 2058: 2057: 1935: 1934: 1742:BASIC Programming 1624: 1623: 1453:or an assignment 1291:Heinz Rutishauser 1144:output parameters 699:is equivalent to 655:A statement like 342:purely functional 326:Single assignment 16:(Redirected from 3264: 3237: 3236: 3218: 3212: 3211: 3193: 3187: 3186: 3168: 3162: 3161: 3140: 3134: 3133: 3119:ANSI Common Lisp 3110: 3104: 3103: 3101: 3100: 3091:. Archived from 3069: 3063: 3062: 3044: 3038: 3037: 3035: 3033: 3019: 3013: 3012: 3010: 3008: 2993: 2987: 2986: 2968: 2962: 2961: 2943: 2937: 2936: 2915: 2909: 2908: 2890: 2884: 2883: 2881: 2880: 2865: 2859: 2858: 2856: 2855: 2841: 2835: 2834: 2832: 2831: 2816: 2810: 2809: 2807: 2806: 2791: 2785: 2784: 2782: 2766: 2760: 2750: 2744: 2743: 2741: 2739: 2724: 2718: 2717: 2715: 2713: 2699: 2693: 2692: 2690: 2688: 2674: 2668: 2659:Computer Journal 2651: 2645: 2644: 2624: 2618: 2617: 2597: 2591: 2590: 2567: 2561: 2560: 2542: 2536: 2530: 2524: 2523: 2521: 2519: 2504: 2498: 2497: 2495: 2493: 2479: 2473: 2472: 2454: 2448: 2447: 2445: 2443: 2420: 2414: 2413: 2411: 2409: 2403: 2397:. Archived from 2392: 2384: 2378: 2377: 2375: 2373: 2347: 2341: 2328: 2313: 2312: 2310: 2308: 2285: 2274: 2273: 2271: 2269: 2260:. Archived from 2250: 2239: 2238: 2236: 2234: 2229:on 24 April 2006 2225:. Archived from 2215: 2196: 2194: 2189: 2168:Immutable object 2138: 2120: 2102: 2083: 2071: 2070: 2049: 2030: 2003: 1981: 1963: 1951: 1950: 1926: 1908: 1890: 1868: 1850: 1832: 1813: 1794: 1775: 1756: 1730: 1712: 1692: 1662: 1644: 1633: 1632: 1538: 1475: 1464: 1463: 1448: 1444: 1418: 1414: 1410: 1406: 1402: 1398: 1394: 1386: 1382: 1371: 1367: 1356: 1352: 1336: 1314: 1287: 1269: 1265: 1257: 1253: 1242: 1239: 1236: 1233: 1230: 1227: 1224: 1221: 1218: 1215: 1212: 1209: 1206: 1203: 1200: 1197: 1194: 1191: 1188: 1185: 1182: 1175: 1167: 1138: 1135: 1132: 1129: 1126: 1123: 1120: 1117: 1114: 1111: 1108: 1105: 1102: 1099: 1096: 1093: 1090: 1087: 1084: 1077: 1074: 1071: 1068: 1065: 1062: 1059: 1056: 1053: 1050: 1047: 1044: 1041: 1038: 1035: 1032: 1029: 1026: 1023: 1020: 1017: 1014: 1011: 1004: 1001: 998: 995: 992: 989: 986: 983: 980: 977: 974: 971: 953: 950: 947: 944: 941: 938: 935: 932: 929: 926: 923: 920: 917: 891: 887: 883: 879: 866: 862: 852: 848: 811: 807: 737: 733: 729: 725: 721: 717: 702: 698: 680: 674: 670: 666: 658: 646: 642: 638: 634: 596: 574: 573: 570: 567: 564: 561: 558: 555: 552: 549: 546: 543: 540: 535: 531: 527: 523: 429: 425: 414: 410: 339: 308: 298: 289: 285: 281: 277: 270: 267: 264: 261: 258: 255: 252: 249: 246: 243: 240: 237: 234: 231: 228: 225: 211: 207: 203: 195: 186: 165: 161: 127:data structuring 97: 75: 21: 3272: 3271: 3267: 3266: 3265: 3263: 3262: 3261: 3242: 3241: 3240: 3233: 3219: 3215: 3208: 3194: 3190: 3183: 3169: 3165: 3158: 3141: 3137: 3130: 3111: 3107: 3098: 3096: 3089: 3070: 3066: 3059: 3045: 3041: 3031: 3029: 3021: 3020: 3016: 3006: 3004: 2995: 2994: 2990: 2983: 2969: 2965: 2958: 2944: 2940: 2933: 2919:Meyer, Bertrand 2916: 2912: 2905: 2891: 2887: 2878: 2876: 2874:Domyassignments 2866: 2862: 2853: 2851: 2843: 2842: 2838: 2829: 2827: 2817: 2813: 2804: 2802: 2793: 2792: 2788: 2769:Niklaus Wirth. 2767: 2763: 2751: 2747: 2737: 2735: 2726: 2725: 2721: 2711: 2709: 2701: 2700: 2696: 2686: 2684: 2676: 2675: 2671: 2664::2:140 (1963). 2652: 2648: 2641: 2625: 2621: 2614: 2598: 2594: 2587: 2568: 2564: 2557: 2543: 2539: 2531: 2527: 2517: 2515: 2506: 2505: 2501: 2491: 2489: 2487:docs.python.org 2481: 2480: 2476: 2469: 2455: 2451: 2441: 2439: 2437: 2421: 2417: 2407: 2405: 2401: 2390: 2386: 2385: 2381: 2371: 2369: 2367: 2348: 2344: 2340:, by Bruce Tate 2338:Wayback Machine 2329: 2316: 2306: 2304: 2302: 2286: 2277: 2267: 2265: 2264:on 4 March 2016 2252: 2251: 2242: 2232: 2230: 2217: 2216: 2209: 2205: 2200: 2199: 2192: 2190: 2186: 2181: 2154: 2130: 2112: 2093: 2074: 2040: 2021: 1995: 1973: 1954: 1918: 1900: 1882: 1872:Macsyma, Maxima 1860: 1842: 1823: 1804: 1785: 1766: 1748: 1722: 1702: 1684: 1654: 1636: 1530: 1467: 1446: 1442: 1435: 1429: 1416: 1412: 1408: 1404: 1400: 1396: 1392: 1384: 1380: 1369: 1365: 1354: 1350: 1334: 1315: 1306: 1285: 1282: 1276: 1267: 1263: 1255: 1251: 1244: 1243: 1240: 1237: 1234: 1231: 1228: 1225: 1223:"foo" 1222: 1219: 1216: 1213: 1210: 1207: 1204: 1201: 1198: 1195: 1192: 1189: 1186: 1183: 1180: 1176:above would be 1173: 1165: 1140: 1139: 1136: 1133: 1130: 1127: 1124: 1121: 1118: 1115: 1112: 1109: 1106: 1103: 1101:"foo" 1100: 1097: 1094: 1091: 1088: 1085: 1082: 1079: 1078: 1075: 1072: 1069: 1066: 1063: 1060: 1057: 1054: 1051: 1048: 1045: 1042: 1040:"foo" 1039: 1036: 1033: 1030: 1027: 1024: 1021: 1018: 1015: 1012: 1009: 1006: 1005: 1002: 999: 996: 993: 990: 987: 984: 981: 978: 975: 972: 969: 955: 954: 951: 948: 945: 942: 939: 936: 933: 930: 927: 924: 921: 918: 915: 909:tuple unpacking 889: 885: 881: 877: 874: 864: 860: 857: 853:. Furthermore, 850: 846: 843: 809: 805: 802: 744: 735: 731: 727: 723: 719: 715: 700: 696: 678: 672: 668: 664: 656: 653: 644: 640: 636: 632: 621: 615: 607:syntactic sugar 603: 594: 571: 568: 565: 562: 559: 556: 553: 550: 547: 544: 541: 538: 533: 529: 525: 521: 507: 427: 416: 412: 408: 399:, avoiding the 338:x := x + 1 337: 334: 328: 304: 303:) and that the 294: 287: 283: 279: 275: 272: 271: 268: 265: 262: 259: 256: 253: 250: 247: 244: 241: 238: 235: 232: 229: 226: 223: 209: 205: 201: 191: 182: 163: 159: 143: 89: 67: 35: 28: 23: 22: 15: 12: 11: 5: 3270: 3260: 3259: 3254: 3239: 3238: 3231: 3213: 3206: 3188: 3181: 3163: 3156: 3144:Steele, Guy L. 3135: 3128: 3105: 3087: 3064: 3057: 3039: 3014: 2988: 2981: 2963: 2956: 2938: 2931: 2910: 2903: 2885: 2860: 2836: 2811: 2786: 2780:10.1.1.88.8309 2761: 2745: 2732:Microsoft Docs 2719: 2694: 2669: 2646: 2639: 2619: 2612: 2592: 2585: 2562: 2555: 2537: 2525: 2499: 2474: 2467: 2449: 2435: 2415: 2379: 2365: 2342: 2314: 2300: 2275: 2240: 2206: 2204: 2201: 2198: 2197: 2183: 2182: 2180: 2177: 2176: 2175: 2170: 2165: 2160: 2153: 2150: 2149: 2148: 2145: 2144: 2139: 2127: 2126: 2121: 2109: 2108: 2103: 2090: 2089: 2084: 2060: 2059: 2056: 2055: 2050: 2037: 2036: 2031: 2018: 2017: 2004: 1992: 1991: 1982: 1970: 1969: 1964: 1937: 1936: 1933: 1932: 1927: 1915: 1914: 1909: 1897: 1896: 1891: 1879: 1878: 1869: 1857: 1856: 1851: 1839: 1838: 1833: 1820: 1819: 1814: 1801: 1800: 1795: 1782: 1781: 1776: 1763: 1762: 1757: 1745: 1744: 1731: 1719: 1718: 1713: 1699: 1698: 1693: 1681: 1680: 1663: 1651: 1650: 1645: 1626: 1625: 1622: 1621: 1539: 1527: 1526: 1476: 1428: 1425: 1389: 1388: 1373: 1358: 1304: 1275: 1272: 1264:a = b, b = a+1 1248:comma operator 1179: 1081: 1008: 968: 914: 869: 855: 838: 800: 743: 740: 652: 649: 617:Main article: 614: 611: 602: 599: 516:(for example, 506: 503: 350:initialization 344:languages. In 327: 324: 222: 198: 197: 188: 142: 139: 26: 9: 6: 4: 3: 2: 3269: 3258: 3255: 3253: 3250: 3249: 3247: 3234: 3232:0-07-000484-6 3228: 3224: 3217: 3209: 3207:0-13-496712-7 3203: 3199: 3192: 3184: 3182:0-13-454646-6 3178: 3174: 3167: 3159: 3157:1-55558-041-6 3153: 3149: 3145: 3139: 3131: 3129:0-13-370875-6 3125: 3121: 3120: 3115: 3109: 3095:on 2009-06-04 3094: 3090: 3088:0-471-43014-5 3084: 3080: 3079: 3074: 3068: 3060: 3058:0-13-790387-1 3054: 3050: 3043: 3028: 3024: 3018: 3002: 2998: 2992: 2984: 2982:0-201-47976-1 2978: 2974: 2967: 2959: 2957:0-13-183872-5 2953: 2949: 2942: 2934: 2932:0-13-247925-7 2928: 2924: 2920: 2914: 2906: 2904:0-470-26939-1 2900: 2896: 2889: 2875: 2871: 2864: 2850: 2846: 2840: 2826: 2822: 2815: 2800: 2796: 2790: 2781: 2776: 2772: 2765: 2758: 2754: 2749: 2733: 2729: 2723: 2708: 2704: 2698: 2683: 2679: 2673: 2667: 2663: 2660: 2656: 2650: 2642: 2640:0-201-71089-7 2636: 2632: 2631: 2623: 2615: 2613:0-596-00085-5 2609: 2605: 2604: 2596: 2588: 2586:1-56592-149-6 2582: 2578: 2577: 2572: 2566: 2558: 2556:0-13-629312-3 2552: 2548: 2541: 2535: 2529: 2513: 2509: 2503: 2488: 2484: 2478: 2470: 2468:0-521-64408-9 2464: 2460: 2453: 2438: 2432: 2428: 2427: 2419: 2404:on 2011-07-16 2400: 2396: 2389: 2383: 2368: 2362: 2358: 2357: 2352: 2346: 2339: 2335: 2332: 2327: 2325: 2323: 2321: 2319: 2303: 2297: 2293: 2292: 2284: 2282: 2280: 2263: 2259: 2255: 2249: 2247: 2245: 2228: 2224: 2220: 2214: 2212: 2207: 2188: 2184: 2174: 2171: 2169: 2166: 2164: 2161: 2159: 2156: 2155: 2143: 2140: 2136: 2133: 2129: 2128: 2125: 2122: 2119: 2116: 2111: 2110: 2107: 2104: 2100: 2097: 2092: 2091: 2088: 2085: 2081: 2078: 2073: 2072: 2069: 2068: 2067: 2065: 2054: 2051: 2048: 2044: 2039: 2038: 2035: 2032: 2029: 2025: 2020: 2019: 2016: 2012: 2008: 2005: 2002: 1998: 1994: 1993: 1990: 1986: 1983: 1980: 1976: 1972: 1971: 1968: 1965: 1962: 1958: 1953: 1952: 1949: 1948: 1947: 1944: 1942: 1939:Mathematical 1931: 1928: 1925: 1921: 1917: 1916: 1913: 1910: 1907: 1904: 1899: 1898: 1895: 1892: 1889: 1885: 1881: 1880: 1877: 1873: 1870: 1867: 1863: 1859: 1858: 1855: 1852: 1849: 1846: 1843:Set-Variable 1841: 1840: 1837: 1834: 1831: 1827: 1822: 1821: 1818: 1815: 1812: 1808: 1803: 1802: 1799: 1796: 1793: 1789: 1784: 1783: 1780: 1777: 1774: 1770: 1765: 1764: 1761: 1758: 1755: 1751: 1747: 1746: 1743: 1739: 1735: 1732: 1729: 1725: 1721: 1720: 1717: 1714: 1710: 1706: 1701: 1700: 1697: 1694: 1691: 1687: 1683: 1682: 1679: 1675: 1671: 1667: 1664: 1661: 1657: 1653: 1652: 1649: 1646: 1643: 1639: 1635: 1634: 1631: 1630: 1629: 1619: 1615: 1611: 1607: 1603: 1599: 1595: 1591: 1587: 1583: 1579: 1575: 1571: 1567: 1563: 1559: 1555: 1551: 1547: 1543: 1540: 1537: 1533: 1529: 1528: 1524: 1520: 1516: 1512: 1508: 1504: 1500: 1496: 1492: 1488: 1484: 1480: 1477: 1474: 1470: 1466: 1465: 1462: 1461: 1460: 1458: 1457: 1452: 1440: 1434: 1424: 1422: 1385:x <- value 1378: 1374: 1363: 1359: 1348: 1344: 1340: 1339: 1338: 1332: 1327: 1325: 1321: 1313: 1309: 1308:Niklaus Wirth 1303: 1298: 1296: 1292: 1281: 1271: 1268:a, b = b, a+1 1261: 1249: 1177: 1171: 1164: 1160: 1156: 1151: 1149: 1145: 966: 964: 960: 912: 910: 906: 902: 898: 893: 872: 868: 854: 841: 837: 835: 831: 827: 823: 819: 815: 799: 797: 793: 789: 785: 781: 777: 773: 769: 765: 762:(since 1.7), 761: 757: 753: 749: 739: 716:i = arr = f() 713: 708: 706: 697:i = arr = f() 694: 690: 685: 681: 676: 662: 657:w = x = y = z 648: 647:is possible. 630: 626: 620: 610: 608: 598: 592: 588: 583: 581: 576: 519: 515: 510: 502: 500: 495: 491: 488: 484: 480: 476: 472: 468: 464: 460: 456: 452: 448: 444: 440: 435: 433: 424: 420: 404: 402: 398: 394: 390: 386: 381: 379: 376:, similar to 375: 371: 367: 362: 357: 355: 351: 347: 343: 333: 323: 320: 316: 312: 307: 302: 297: 291: 220: 218: 213: 206:a := 2*a 194: 189: 185: 180: 179: 178: 176: 171: 167: 157: 153: 148: 138: 136: 132: 128: 124: 120: 116: 111: 109: 105: 101: 96: 92: 87: 83: 79: 74: 70: 64: 62: 59: 55: 52: 48: 44: 40: 33: 19: 3222: 3216: 3197: 3191: 3172: 3166: 3147: 3138: 3118: 3114:Graham, Paul 3108: 3097:. Retrieved 3093:the original 3077: 3067: 3048: 3042: 3030:. Retrieved 3026: 3017: 3005:. Retrieved 3000: 2991: 2972: 2966: 2947: 2941: 2922: 2913: 2894: 2888: 2877:. Retrieved 2873: 2863: 2852:. Retrieved 2848: 2839: 2828:. Retrieved 2824: 2814: 2803:. Retrieved 2801:. 2013-06-01 2798: 2789: 2764: 2753:Effective Go 2748: 2736:. Retrieved 2731: 2722: 2710:. Retrieved 2707:MDN Web Docs 2706: 2697: 2685:. Retrieved 2681: 2672: 2661: 2658: 2654: 2653:D.W. Barron 2649: 2629: 2622: 2602: 2595: 2575: 2565: 2546: 2540: 2528: 2516:. Retrieved 2511: 2502: 2490:. Retrieved 2486: 2477: 2458: 2452: 2440:. Retrieved 2425: 2418: 2406:. Retrieved 2399:the original 2394: 2382: 2370:. Retrieved 2355: 2345: 2305:. Retrieved 2290: 2266:. Retrieved 2262:the original 2257: 2231:. Retrieved 2227:the original 2222: 2187: 2134: 2131: 2117: 2114: 2098: 2095: 2079: 2076: 2061: 2046: 2042: 2027: 2023: 2000: 1996: 1978: 1974: 1960: 1956: 1945: 1938: 1923: 1919: 1905: 1902: 1887: 1883: 1865: 1861: 1848:(expression) 1847: 1844: 1829: 1825: 1810: 1806: 1791: 1787: 1772: 1768: 1753: 1749: 1727: 1723: 1708: 1704: 1689: 1685: 1659: 1655: 1641: 1637: 1627: 1535: 1531: 1503:Bourne shell 1472: 1468: 1454: 1450: 1436: 1390: 1328: 1317: 1311: 1300: 1293:'s language 1283: 1252:a = 1, b = 2 1245: 1154: 1152: 1141: 956: 894: 880:leaves both 875: 870: 858: 844: 839: 833: 829: 825: 821: 813: 803: 745: 709: 686: 682: 677: 660: 659:is called a 654: 622: 604: 584: 577: 511: 508: 498: 493: 487:backtracking 477:(for vals), 436: 422: 418: 405: 388: 382: 365: 358: 354:name binding 349: 335: 305: 295: 292: 273: 214: 199: 192: 183: 168: 144: 112: 98:(originally 94: 90: 76:(originally 72: 68: 65: 42: 36: 2849:gcc.gnu.org 2734:. Microsoft 2571:Wall, Larry 2534:Assignments 2514:. LispWorks 2307:25 December 2087:Common Lisp 1989:Casio BASIC 1941:pseudo code 1817:AppleScript 1491:descendants 1439:equals sign 1256:a, b = 1, 2 1254:instead of 1184:Deconstruct 1166:Deconstruct 752:Common Lisp 483:Standard ML 361:side effect 3246:Categories 3099:2010-05-09 3027:golang.org 3001:python.org 2879:2024-06-21 2854:2024-06-21 2830:2024-06-21 2805:2024-06-21 2799:ntu.edu.sg 2203:References 2132:expression 2118:expression 2099:expression 2080:expression 2043:expression 2024:expression 1997:expression 1975:expression 1957:expression 1906:expression 1888:expression 1866:expression 1854:PowerShell 1830:expression 1811:expression 1792:expression 1773:expression 1754:expression 1728:expression 1709:expression 1690:expression 1688:<<- 1660:expression 1642:expression 1618:AutoHotkey 1536:expression 1519:PowerShell 1473:expression 1431:See also: 1278:See also: 796:PowerShell 760:JavaScript 455:JavaScript 391:, for the 330:See also: 296:expression 184:expression 58:imperative 2775:CiteSeerX 2738:29 August 2442:3 January 2372:3 January 1922: :- 1790: := 1738:Smalltalk 1640:<< 1578:Smalltalk 1534: := 1501:, etc.), 1451:statement 1295:Superplan 1260:for loops 1163:extension 849:and 1 to 830:unpacking 808:and 1 to 591:unit type 522:x = y = a 499:on demand 389:on-demand 175:variables 170:Variables 152:iteration 141:Semantics 93: := 84:1957 and 78:Superplan 3146:(1990). 3116:(1996). 3075:(1962). 3032:20 April 2921:(1992). 2712:20 April 2687:20 April 2518:23 April 2492:20 April 2408:20 April 2353:(2003). 2334:Archived 2268:20 April 2233:20 April 2152:See also 2135:variable 2115:variable 2096:variable 2077:variable 2047:variable 2034:LiveCode 2028:variable 2001:variable 1985:TI-BASIC 1979:variable 1961:variable 1903:variable 1884:variable 1864: : 1862:variable 1845:variable 1826:variable 1807:variable 1788:variable 1769:variable 1750:variable 1724:variable 1705:variable 1703:assign(" 1686:variable 1656:variable 1638:variable 1532:variable 1493:such as 1469:variable 1456:operator 1427:Notation 1407:" when " 1383:, as in 1324:equality 1305:—  1159:instance 512:In most 494:explicit 306:variable 193:variable 158:such as 108:operator 51:variable 3007:4 March 2825:lwn.net 2395:gwu.edu 2258:uah.edu 2191:Use of 2137: ! 1836:C shell 1525:, etc. 1479:Fortran 776:occam 2 637:a = 2*a 631:, like 587:Haskell 551:getchar 451:Haskell 439:Clojure 432:mutable 385:Haskell 319:dynamic 82:Fortran 3229:  3204:  3179:  3154:  3126:  3085:  3055:  2979:  2954:  2929:  2901:  2777:  2655:et al. 2637:  2610:  2583:  2553:  2465:  2433:  2363:  2298:  2106:Scheme 2094:(set! 2075:(setf 1999:-> 1930:Simula 1798:XQuery 1658:<- 1598:Python 1586:Oberon 1582:Eiffel 1562:Modula 1558:Pascal 1546:Simula 1507:Python 1347:Pascal 1193:string 1016:string 925:return 905:Python 876:since 794:, and 784:Python 712:Python 641:a *= 2 580:Scheme 490:Prolog 485:. Non- 467:Racket 443:Erlang 315:lvalue 301:rvalue 219:code: 104:Pascal 2402:(PDF) 2391:(PDF) 2179:Notes 2142:Forth 2026:into 2007:POP-2 1967:COBOL 1955:MOVE 1894:Rebol 1779:BASIC 1670:OCaml 1648:Magik 1620:etc. 1594:Seed7 1590:Dylan 1542:ALGOL 1489:(and 1381:<- 1343:ALGOL 1331:BASIC 1170:class 1034:=> 788:REBOL 768:Maple 703:. In 669:w, x, 635:, so 539:while 526:y = a 479:SISAL 475:Scala 459:OCaml 428:<- 423:value 311:const 266:32.4f 239:float 164:STORE 115:scope 100:ALGOL 47:value 41:, an 3227:ISBN 3202:ISBN 3177:ISBN 3152:ISBN 3124:ISBN 3083:ISBN 3053:ISBN 3034:2018 3009:2020 2977:ISBN 2952:ISBN 2927:ISBN 2899:ISBN 2740:2019 2714:2018 2689:2018 2635:ISBN 2608:ISBN 2581:ISBN 2551:ISBN 2520:2019 2494:2018 2463:ISBN 2444:2011 2431:ISBN 2410:2018 2374:2011 2361:ISBN 2309:2010 2296:ISBN 2270:2018 2235:2018 2113:set 2064:Lisp 2041:PUT 2022:put 2011:BETA 1901:var 1824:set 1805:set 1786:let 1767:LET 1610:AMPL 1570:PL/M 1566:Mary 1554:BCPL 1499:Java 1483:PL/I 1417:then 1399:", " 1395:", " 1370:"==" 1351:":=" 1345:and 1181:void 963:Rust 961:and 903:and 884:and 863:and 792:Ruby 780:Perl 671:and 471:SASL 419:name 417:let 413:set! 393:lazy 372:and 370:LISP 190:The 181:The 160:MOVE 133:and 95:expr 73:expr 54:name 2757:for 2124:Tcl 2053:ABC 2045:IN 1959:TO 1809:to 1752:=: 1734:APL 1707:", 1574:Ada 1564:), 1550:CPL 1523:Nim 1495:C++ 1421:gcc 1375:In 1366:"=" 1360:In 1355:"=" 1341:In 1335:"=" 1205:int 1202:out 1190:out 1174:f() 1161:or 1148:CLU 1137:(); 1113:let 1086:let 1076:(); 1052:var 1022:int 922:(): 916:def 871:var 840:var 832:or 818:CPL 772:Lua 764:PHP 748:APL 728:arr 720:f() 710:In 705:C++ 585:In 560:EOF 554:()) 501:). 409:let 364:as 224:int 162:or 37:In 3248:: 3025:. 2999:. 2872:. 2847:. 2823:. 2797:. 2773:. 2755:: 2730:. 2705:. 2680:. 2510:. 2485:. 2393:. 2317:^ 2278:^ 2256:. 2243:^ 2221:. 2210:^ 2013:, 2009:, 1987:, 1977:→ 1886:: 1874:, 1828:= 1771:= 1740:, 1736:, 1726:← 1676:, 1672:, 1668:, 1666:F# 1614:ML 1612:, 1608:, 1606:Io 1602:Go 1596:, 1592:, 1588:, 1584:, 1580:, 1576:, 1572:, 1568:, 1556:, 1552:, 1548:, 1521:, 1517:, 1511:Go 1509:, 1505:, 1497:, 1485:, 1481:, 1471:= 1447::= 1413:if 1409:== 1401::= 1397:== 1372:). 1357:). 1310:, 1110:); 1095:|| 1049:); 1031:() 1003:); 959:C# 952:() 901:F# 899:, 897:Go 892:. 836:: 790:, 786:, 782:, 778:, 774:, 770:, 766:, 758:, 756:Go 754:, 750:, 633:*= 595:() 557:!= 545:ch 542:(( 481:, 473:, 463:Oz 461:, 453:, 449:, 447:F# 421:= 380:. 313:) 254:23 233:10 166:. 137:. 129:, 71:= 3235:. 3210:. 3185:. 3160:. 3132:. 3102:. 3061:. 3036:. 3011:. 2985:. 2960:. 2935:. 2907:. 2882:. 2857:. 2833:. 2808:. 2783:. 2742:. 2716:. 2691:. 2662:6 2643:. 2616:. 2589:. 2559:. 2522:. 2496:. 2471:. 2446:. 2412:. 2376:. 2311:. 2272:. 2237:. 2193:= 2101:) 2082:) 2015:R 1876:K 1760:J 1716:R 1711:) 1696:R 1678:S 1674:R 1515:R 1487:C 1443:= 1441:( 1405:= 1393:= 1377:R 1362:C 1286:= 1241:} 1238:; 1235:1 1232:= 1229:b 1226:; 1220:= 1217:a 1214:{ 1211:) 1208:b 1199:, 1196:a 1187:( 1134:f 1131:= 1128:) 1125:b 1122:, 1119:a 1116:( 1107:1 1104:, 1098:( 1092:= 1089:f 1073:f 1070:= 1067:) 1064:b 1061:, 1058:a 1055:( 1046:1 1043:, 1037:( 1028:f 1025:) 1019:, 1013:( 1000:a 997:, 994:b 991:( 988:= 985:) 982:b 979:, 976:a 973:( 949:f 946:= 943:b 940:, 937:a 934:2 931:, 928:1 919:f 890:b 886:b 882:a 865:b 861:a 851:b 847:a 810:b 806:a 732:i 724:i 689:C 673:y 665:z 645:a 625:C 572:} 569:… 566:{ 563:) 548:= 534:x 530:a 518:C 288:y 284:x 280:y 276:x 269:; 263:= 260:y 257:; 251:= 248:x 245:; 242:y 236:; 230:= 227:x 217:C 210:a 202:a 91:x 86:C 69:x 34:. 20:)

Index

Assignment operation
Drive letter assignment
computer programming
value
variable
name
imperative
programming languages
Superplan
Fortran
C
ALGOL
Pascal
operator
scope
strictly functional
referential transparency
data structuring
structured programming
object orientation
imperative programming
iteration
machine operations
Variables
variables
C
rvalue
const
lvalue
dynamic

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.