octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

repeated var in output argument


From: John W. Eaton
Subject: repeated var in output argument
Date: Wed, 12 Dec 2007 13:52:05 -0500

On 11-Dec-2007, Dupuis wrote:

| 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 ?

If you also want a warning if the same expression is repeated, then I
don't see a simple way to do it.

Perhaps it would be better to rework the way the printing is done in
the tree_multi_assignment::rvalue (int) function in src/pt-assign.cc
so that instead of doing

  loop over all elements
    perform assignment
    print
  end loop

we do

  loop over all elements
    perform assignment
  end loop

  loop over all elements
    print
  end loop

but this change might not be trivial given the current
implementation.  I'd consider a patch, but not until after 3.0.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]