help-octave
[Top][All Lists]
Advanced

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

Re: looping over file objects


From: John W. Eaton
Subject: Re: looping over file objects
Date: Fri, 14 Nov 2003 09:46:29 -0600

On 14-Nov-2003, Przemek Klosowski <address@hidden> wrote:

| fopen() already returns the second optional value (the error message),
| so we could just extend that:
| 
|  - return additional, structure value for three return arguments:
| 
|     fopen('abc')  => ans=3
|     [a,msg,b]=fopen('abc') => a=3, msg='', 
b={id=3,name=abc,mode=r,arch=native,status=open}

This seems OK.

|  - return individual items: [fd,msg,nam,mod,arch,stat]=fopen('abc'); 

Also OK, but I think I'd prefer a stream object.  OTOH, this is
somewhat more consistent with the behavior of what fopen (fid) returns
for an open file.

Another possibility would be to add an additional argument to fopen
that would tell it to return a stream object instead of just the file id.

|  - detecting what is the return argument type (not only their number),
|    and returning a structure if it is a structure, and a scalar
|    otherwise (I am not sure whether the interpreter does this
|    currently---if not, this may require larger changes)
| 
| I always liked Perl's convention of 'context': various Perl functions
| and objects return different values depending on whether they are used
| in array or scalar context.

I think this makes sense in Perl because of the distinction between
scalar and array objects ($ vs @) but its probably not the right thing
for Octave.

jwe



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