On Sat, 28 Jan 2017, Sven Schreiber wrote:
Am 27.01.2017 um 18:34 schrieb Marcin Błażejowski:
> W dniu 27.01.2017 o 18:03, Sven Schreiber pisze:
>> In principle one could argue that transp(m) and m[diag] are not that
>> different, in that they juggle around (some of) the elements of the
> m[diag] = {3, 3} can be written as
> loop i=1 to 2
> m[i,i] = 3
> endloop
> end m[i,i] is correct lvalue (in C).
Well, I can also write instead of transp(m) = my_matrix:
loop i=1..rows(m)
loop j=1..cols(m)
m[j, i] = my_matrix[i, j]
endloop
endloop
I'd say transp() is just another case of a certain indexing in a sense,
so it's just a matter of what's implemented and what's not.
Acceptable targets for assignment (lvalues) are just named objects
or "members" of named objects (which might be identified by name or
by indexing, depending on the character of the "parent" object. (And
"diag" is just a special case of indexing.)
So given a matrix m, the following are all (in principle) acceptable
lvalues:
m
m[1,1]
m[diag]
transp(m), on the other hand is a function that returns a
free-standing, anonymous object, which is not a valid target for
assignment. We could, in principle, define a "transp" shorthand
analogous to "diag", such that m[transp] would be a valid lvalue
(another special case of indexing) but this seems tricksy and not
something we'd really want to do.
Allin