octave-maintainers
[Top][All Lists]
Advanced

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

fn().field broken?


From: John W. Eaton
Subject: fn().field broken?
Date: Mon, 9 Sep 2002 13:40:45 -0500

On  8-Sep-2002, John W. Eaton <address@hidden> wrote:

| On  8-Sep-2002, Paul Kienzle <address@hidden> wrote:
| 
| | I am surprised that
| |     stat("test.jpg").size
| | returns the entire structure instead of just the size element.  Is this
| | behaviour expected?
| 
| No, it looks like a bug.  I'll try to fix this soon.

I've checked in the following patch.

Note the comment I added:

  // XXX FIXME XXX -- Note that if a function call returns multiple
  // values, and there is further indexing to perform, then we are
  // ignoring all but the first value.  Is this really what we want to
  // do?  If it is not, then what should happen for stat("file").size,
  // for exmaple?

Currently, some functions (like stat) return multiple values even when
nargout is only 0 or 1, and then the extra values are simply ignored.
I think it's easier to implement some of these functions if that's the
way things work.  I suppose we could tighten up the error checking
here if we required functions to only return as many values as
requested, but that seems like a lot of extra work to do.  Or, we
could only allow further indexing when nargout is 0 or 1.  What do you
think?

Thanks,

jwe


Index: src/ov-builtin.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/ov-builtin.cc,v
retrieving revision 1.5
diff -u -r1.5 ov-builtin.cc
--- src/ov-builtin.cc   15 May 2002 03:21:00 -0000      1.5
+++ src/ov-builtin.cc   9 Sep 2002 18:29:44 -0000
@@ -76,10 +76,20 @@
       panic_impossible ();
     }
 
-  return retval;
+  // XXX FIXME XXX -- perhaps there should be an
+  // octave_value_list::next_subsref member function?  See also
+  // octave_user_function::subsref.
+  //
+  // XXX FIXME XXX -- Note that if a function call returns multiple
+  // values, and there is further indexing to perform, then we are
+  // ignoring all but the first value.  Is this really what we want to
+  // do?  If it is not, then what should happen for stat("file").size,
+  // for exmaple?
+
+  if (idx.length () > 1)
+    retval = retval(0).next_subsref (type, idx);
 
-  // XXX FIXME XXX
-  //  return retval.next_subsref (type, idx);
+  return retval;
 }
 
 octave_value_list
Index: src/ov-usr-fcn.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/ov-usr-fcn.cc,v
retrieving revision 1.29
diff -u -r1.29 ov-usr-fcn.cc
--- src/ov-usr-fcn.cc   4 Jul 2002 17:43:00 -0000       1.29
+++ src/ov-usr-fcn.cc   9 Sep 2002 18:29:45 -0000
@@ -328,10 +328,14 @@
       panic_impossible ();
     }
 
-  return retval;
+  // XXX FIXME XXX -- perhaps there should be an
+  // octave_value_list::next_subsref member function?  See also
+  // octave_builtin::subsref.
+
+  if (idx.length () > 1)
+    retval = retval(0).next_subsref (type, idx);
 
-  // XXX FIXME XXX
-  //  return retval.next_subsref (type, idx);
+  return retval;
 }
 
 octave_value_list



reply via email to

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