help-octave
[Top][All Lists]
Advanced

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

Re: cs-lists, structure arrays ....


From: John W. Eaton
Subject: Re: cs-lists, structure arrays ....
Date: Tue, 5 Apr 2005 09:36:39 -0400

On  5-Apr-2005, David Bateman <address@hidden> wrote:

| So the only way I see to deal with strings in a structure array 
| is if octave allowed "[a0, a1, ...] = cs_list" and frankly you'd also 
| need "[x{:}] = cs_list". I'm not sure how much effort that would be to 
| implement though...

Handling the first form is easy (see the patch below).  The second
one is a lot harder, at least in the general case, because you can
have things like

  [x(3).y{:}] = some_function ()

so you have to evaluate (with some care) the LHS of the assignment
to determine what the value of nargin should be for the call to
some_function.  Normally, Octave does not evaluate the LHS of an
assignment before evaluating the RHS.  So handling this form properly
requires some relatively ugly changes.

jwe


src/ChangeLog:

2005-04-05  John W. Eaton  <address@hidden>

        * pt-assign.cc (tree_multi_assignment::rvalue):
        Allow assignments of the form [a,b,c] = x{:}.

 
Index: src/pt-assign.cc
===================================================================
RCS file: /cvs/octave/src/pt-assign.cc,v
retrieving revision 1.24
diff -u -r1.24 pt-assign.cc
--- src/pt-assign.cc    28 Dec 2004 03:36:14 -0000      1.24
+++ src/pt-assign.cc    5 Apr 2005 13:27:08 -0000
@@ -224,6 +224,18 @@
 
          int n = rhs_val.length ();
 
+         if (n == 1)
+           {
+             octave_value tmp = rhs_val(0);
+
+             if (tmp.is_cs_list ())
+               {
+                 rhs_val = tmp.list_value ();
+
+                 n = rhs_val.length ();
+               }
+           }
+
          retval.resize (n, octave_value ());
 
          for (tree_argument_list::iterator p = lhs->begin ();



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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