Hello,
I recently tracked down a bug in a program I wrote due to a typo in the names of output variables, so one of them was repeated twice. Basically something as
[U, S, S]=svd(randn(3,3)) # correct: [U, S, V] = ...
but, due to the length of the line, I didn't notice until close inspection.
Now, a funny thing: octave is not bug-to-bug compatible with matlab with regard to this behaviour.
Octave 2.9.19 : print S a first time with values only on the main diagonal, and a second time as a unitary matrix.
Matlab 6.1 : print S the two times as a unitary matrix
Afterwards, in both case, S contains the unitary matrix, the diagonal matrix is lost.
Would it be possible to issue a warning if some variable is repeated in the output arguments of a function call ? This is a stupid typo, but as problematic as
if (x=1) # instead of (x==1)
In the first place, this is a problem in the way the function call is written. I would find interesting to add a feature to detect such overwriting of variables.
Best regards
Pascal Dupuis