help-octave
[Top][All Lists]
Advanced

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

Re: equivalent for C-style init: structname varname[] = {...} ?


From: Sergei Steshenko
Subject: Re: equivalent for C-style init: structname varname[] = {...} ?
Date: Sat, 17 Nov 2012 17:48:39 -0800 (PST)




----- Original Message -----
> From: Ben Abbott <address@hidden>
> To: Sergei Steshenko <address@hidden>
> Cc: Jordi Gutiérrez Hermoso <address@hidden>; Yury T. <address@hidden>; 
> "address@hidden" <address@hidden>
> Sent: Sunday, November 18, 2012 2:44 AM
> Subject: Re: equivalent for C-style init: structname varname[] = {...} ?
> 
> On Nov 16, 2012, at 10:10 PM, Sergei Steshenko wrote:
> 
>>  ----- Original Message -----
>>>  From: Jordi Gutiérrez Hermoso <address@hidden>
>>>  To: Sergei Steshenko <address@hidden>
>>>  Cc: Yury T. <address@hidden>; 
> "address@hidden" <address@hidden>
>>>  Sent: Friday, November 16, 2012 12:55 AM
>>>  Subject: Re: equivalent for C-style init: structname varname[] = {...} 
> ?
>>> 
>>>  On 15 November 2012 12:50, Sergei Steshenko <address@hidden> 
> wrote:
>>>>  - why am I getting an error here ?
>>>> 
>>>>  Now:
>>>> 
>>>>  "
>>>>  octave:5> s = struct();
>>>>  octave:6> setfield(s, "foo bar", "doo")
>>>>  ans =
>>>> 
>>>>     scalar structure containing the fields:
>>>> 
>>>>       foo bar = doo
>>>>  "
>>>> 
>>>>  - no error.
>>>> 
>>>>  Tell me again how consistent struct behavior in Octave is.
>>> 
>>>  Sure:
>>> 
>>>     http://hg.savannah.gnu.org/hgweb/octave/rev/126285fce876
>>> 
>>>  Fixed,
>>>  - Jordi G. H.
>> 
>>  So, if "foo bar" a valid key or not ? If not - why ?
> 
> I suppose it is assumed necessary that field names be used as ....
> 
>     s = struct ();
>     setfield (s, "foo")
>     s.("foo")
>     s.foo
> 
> The syntax for the last would fail for "foo bar".
> 
> Ben


What is wrong with "foo bar" associative array key ? In Octave structs are 
associative arrays.

I am not aware of languages forbidding presence of whitespaces in hash keys.


Why 's.("foo bar")' should fail when 'setfield(s, "foo bare")', 'getfield(s, 
"foo bar")' does not fail ? I.e. why syntax sugar/shortcut in the form s.("foo 
bar") should be illegal while the full form access through setfield/getfield 
accepts "foo bar" ?


Thanks,
  Sergei.


>


reply via email to

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