help-octave
[Top][All Lists]
Advanced

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

Re: foo_cs = foo{:} - feature or bug ? (octave-3.4.2); also, sizeof(foo{


From: Ben Abbott
Subject: Re: foo_cs = foo{:} - feature or bug ? (octave-3.4.2); also, sizeof(foo{:})
Date: Wed, 10 Aug 2011 14:57:59 -0400

On Aug 9, 2011, at 10:27 AM, Ben Abbott wrote:

> On Aug 9, 2011, at 1:27 AM, Sergei Steshenko wrote:
> 
>> "
>> octave:3> foo_cs = foo{:}
>> foo_cs =  1
>> "
>> 
>> part looks like a (awkward) way of taking/making a value out of a list,
>> that is why I expect 'sizeof' to work on that value - because it _does_
>> work on '1 + 2' expression.
> 
> I agree. It is an awkward and confusing way to assign a value. I'd avoid 
> using such syntax.
> 
> My impression is that you understand what cs-lists, are and how they work. 
> But just in case, below, there is a brief description of how cs-lists are 
> used in Octave. Let me know if there is some part that isn't clear.
> 
> 
> The term <cs-list> is short hand for _comma_separated_list_of_objects_.
> If an octave session has objects A, B, and C, then a <cs-list> of these 
> objects would be "A, B, C".
> 
> <cs-lists> are used by the m-file language as inputs to functions, "fun 
> (<cs-list>)", and as outputs to functions, "[<cs-list>] = fun (<cs-list>)".
> 
> <cs-lists> are also used when creating objects.  An object, with an array of 
> values, is created by enclosing a <cs-list> in square brackes, "A = [1, 2, 
> 3]". In this case the <cs-list> is "1, 2, 3".
> 
> An array of objects is created by enclosing a <cs-list> in curly brackets, "B 
> = {pi, true, 'foobar'}".  In this case the <cs-list> is "pi, true, 'foobar'". 
>  Arrays of objects are refered to a cells, and are objects themselves.
> 
> Using Octave's parser, <cs-lists> may be produced from either cell or 
> structure objects. If "B" is a cell object, a <cs-list> is produced by 
> "B{m:n}" or just "B{:}". If "S" is a structure, a <cs-list> is produced by 
> "S(m:n).field", or just "S(:).field".
> 
> 
> Ben

I just noticed that the manual has a good description of cs-lists in section 
6.3.

Ben



reply via email to

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