octave-maintainers
[Top][All Lists]
Advanced

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

Re: struct arrays and cs-lists


From: Olaf Till
Subject: Re: struct arrays and cs-lists
Date: Tue, 13 Nov 2012 20:16:58 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

On Tue, Nov 13, 2012 at 01:26:39PM -0500, John W. Eaton wrote:
> On 13-Nov-2012, Jordi Gutiérrez Hermoso wrote:
> 
> | This sounds nice, but is this really how things would need to be?
> 
> Maybe not.
> 
> | Are the cs-lists you get from s.foo just a weird wart in the language?
> 
> I think they are.
> 
> You've said a number of times that a struct array is like a cell array
> except that one index of the struct array is a character string.
> That's a reasonable conceptual model, but as you see, the details
> don't quite allow you to work with struct arrays in a way that fits
> your conceptual model.
> 
> Currently, you can write
> 
>   s(i,j,k,...)
> 
> to index elements of a struct array for all fields.  Would it be
> acceptable to extend this form of indexing to allow
> 
>   s(cellstr)
> 
> to index a struct array by fieldnames and
> 
>   s(cellstr, i, j, k, ...)
> 
> to index a struct array by fieldnames and element indices?  I haven't
> given it a lot of thought, so maybe there are some problems with this
> proposal that I'm not seeing.  But my first impression is that it
> should be possible to make this form of indexing work and I think it
> would give you the behavior that you want.
> 
> The cellstr index would have to contain a list of fieldnames contained
> in the struct array S and the result would be another struct array.

Wasn't the original desire to have a cell-array returned? I'm
confused, now Jordi says this solution is good ... (I didn't see this
post before my last post).

Olaf

> As a special case, cellstr could also be a single character string if
> you only need to index a single field.
> 
> jwe

-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

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