[Top][All Lists]

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

Re: getstruct, setstruct, etc.

From: Paul Kienzle
Subject: Re: getstruct, setstruct, etc.
Date: Thu, 22 Jul 2004 17:24:21 -0400

On Jul 22, 2004, at 4:03 PM, Andy Adler wrote:

On Jul 21, 2004, at 4:21 PM, Andy Adler wrote:

Is anyone feel strongly about changing the octave-forge functions
to be closer to Matlab?

I would prefer it, but getfield/setfield are used elsewhere in
so make sure they don't break.

You should probably keep the old versions around but rename them
to make it easier for those who depend on the existing  behaviour in
their private scripts.

The only parts of octave-forge that depend on this behaviour are:

./main/struct/test_struct.m:     # this is obvious
./main/vrml/                     # many functions

I can modify this. Any ideas on what to rename them to?

Since the existing functions allow get/set on multiple fields
simultaneously, I suggest getfields and setfields.

Etienne, any comments?

Here is my proposed fix. They're written as *.m files, but that
should be OK since this syntax is deprecated anyway.

Having to use eval is kind of ugly.  It seems like there should
be a recursive solution like:

                return s
                return getfield(s(idx).(field)(idx),...)


                s = v
                return s
                s(idx).(field)(idx) = setfield(s(idx).(field)(idx),...,v)
                return s

I don't know that it would be any faster though.  And setfield
will fail if field does not already exist.  So eval it is.

- Paul

reply via email to

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