help-octave
[Top][All Lists]
Advanced

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

Re: accessing "sub-structs"


From: Thorsten Meyer
Subject: Re: accessing "sub-structs"
Date: Sat, 06 Jun 2009 19:44:58 +0200
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

John W. Eaton wrote:
> On  6-Jun-2009, Jaroslav Hajek wrote:
>
> | Some time ago there was a proposal to allow cs-lists being specified
> | as dynamic field indices, i.e.
> | 
> | ss = s.(fields{:}); # fields is a cell array
> | ss = s.("a","b");
>
> Since s.("a") produces a cs-list, I would think that s.("a", "b")
> should also produce a cs-list, probably with the with the "a" elements
> followed by the "b" elements, so
>
>   ss = s.("a", "b")
>
> would not make sense, but
>
>   ss = {s.("a", "b")}
>
> would.
>   
I think you are right: to be consistent with existing syntax s.("a",
"b") would have to return a cs-list. Yet, what I am looking for is
something, that returns a structure which contains some of the fields of
the original structure. 

Hmm, for a new language, I would propose to let s.("a","b") return a
substructure and s.{"a","b"} a cs-list - consistent with the use of ()
and {} on cell arrays. Can matlab index structures with s.("a") now?
> | But I would prefer to see examples of real-life usage first.
>
> I agree.  Would this change solve a problem that actually comes up
> often enough to justify the effort of implementing the feature?  Also,
> if we make a change like this, it's possible that the MathWorks will
> introduce some other meaning for the same syntax in Matlab, and then
> we would likely be forced to change Octave.  I'd rather avoid that.
>   
My current need for extracting substructures comes from dealing with
plots. E.g., I would like to get the current plot object with
   get(h)
and extract the options, which are needed to later reproduce the plot
(and I like keeping plot options in a structure ...).

Thorsten


reply via email to

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