octave-maintainers
[Top][All Lists]
Advanced

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

dynamic field names for structures


From: John W. Eaton
Subject: dynamic field names for structures
Date: Tue, 29 Oct 2002 11:19:44 -0600

On 25-Oct-2002, Paul Kienzle <address@hidden> wrote:

| Have you ever considered accepting string indices for structure
| variables so that instead of
| 
|       eval(["x.",el])
| 
| or
| 
|       getfield(x,el)
| 
| You could write
| 
|       x(el)
| 
| ?  I presume for an array of structures, this would be
| 
|       x(i,j)(el)
| 
| Just a thought.

I just checked in some changes to Octave that allow

  x.(el)

and

  x(i,j).(el)

when el is an expression that evaluates to a string.  This syntax
should be compatible with Matlab R13.

This also makes getfield and setfield obsolete, and the Matlab docs
now say that those functions are deprecated.  In any case, I think it
should now be possible to implement Matlab-compatible getfield and
setfield functions in an M-file using the new syntax.  If not, please
let me know what additional features are required to make it work.

Thanks,

jwe



reply via email to

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