6 a = {e_1, e_2, ...[ { ... } ] }
9 a lvalue, current value a structure in { } case
13 e_0, e_1, ... expressions, blanks, or initializer lists
19 Here an lvalue is either a simple variable specified by an identifier,
20 or an element of an existing structure specified by one or more
21 qualifiers following an identifier.
23 An initializer list is a comma-separated list enclosed in braces as in
27 where each e_i is an expression, blank or initializer list.
29 a = b evaluates b, assigns its value to a, and returns a.
31 a = {e_0, e_1, ... } where the e_i are expressions or blanks,
32 requires the current value of a to be a matrix, list
33 or object with at least as many elements as listed e_i. Each non-blank
34 e_i is evaluated and its value is assigned to a[[i]]; elements a[[i]]
35 corresponding to blank e_i are unchanged.
37 If, in a = {e_0, e_1, ...}, e_i is an initializer list, as in
38 {e_i_0, e_1_1, ...}, the corresponding a[[i]] is to be a matrix, list
39 or object with at least as many elements as listed e_i_j. Depending on
40 whether e_i_j is an expression, blank, or initializer list, one, no, or
41 possibly more than one assignment, is made to a[[i]][[j]] or, if
42 relevant and possible, its elements.
44 In simple assignments, = associates from right to left so that, for
49 has the effect of a = (b = c) and results in assigning the value of c
50 to both a and b. The expression (a = b) = c is acceptable, but has the
51 effect of a = b; a = c; in which the first assignment is superseded by
54 In initializations, = { ...} associates from left to right so that,
57 a = {e_0, ... } = {v_0, ...}
59 first assigns e_0, ... to the elements of a, and then assigns v_0, ...
62 If there are side effects in the evaluations involved in executing a = b,
63 it should be noted that the order of evaluations is: first the address
64 for a, then the value of b, and finally the assignment. For example if
65 A is a matrix and i = 0, then the assignment in A[i++] = A[i] is
68 If, in execution of a = b, a is changed by the evaluation of b, the
69 value of b may be stored in an unintended or inaccessible location. For
74 results in the value 3 being stored not only as the new value for A
75 but also at the now unnamed location earlier used for A[0].
85 ; mat A[3] = {1, list(2,3), obj point = {4,5}}
87 ; A[1][[0]] = 6; A[2].x = 7
90 list (2 elements, 2 nonzero):
97 ; A = {A[2], , {9,10}}
107 list (2 elements, 2 nonzero):
120 ## Copyright (C) 1999 Landon Curt Noll
122 ## Calc is open software; you can redistribute it and/or modify it under
123 ## the terms of the version 2.1 of the GNU Lesser General Public License
124 ## as published by the Free Software Foundation.
126 ## Calc is distributed in the hope that it will be useful, but WITHOUT
127 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
128 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
129 ## Public License for more details.
131 ## A copy of version 2.1 of the GNU Lesser General Public License is
132 ## distributed with calc under the filename COPYING-LGPL. You should have
133 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
134 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
136 ## @(#) $Revision: 30.1 $
137 ## @(#) $Id: assign,v 30.1 2007/03/16 11:10:42 chongo Exp $
138 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/assign,v $
140 ## Under source code control: 1995/05/11 21:03:23
141 ## File existed as early as: 1995
143 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
144 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/