[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: |
Mon, 19 Nov 2012 17:26:03 -0800 (PST) |
----- Original Message -----
> From: Dimitri Maziuk <address@hidden>
> To: Sergei Steshenko <address@hidden>
> Cc: "address@hidden" <address@hidden>
> Sent: Monday, November 19, 2012 5:34 PM
> Subject: Re: equivalent for C-style init: structname varname[] = {...} ?
>
> On 11/18/2012 11:42 AM, Sergei Steshenko wrote:
>>
>> "have mixed-type fields" - "foo" and "foo
> bar" are _both_ strings, so it's the same type.
>>
>> I suggest to read http://en.wikipedia.org/wiki/Hash_table first.
>>
>> "two" and 2 would be different types (string vs (integer)
> number), but it's not what I was talking about.
>
> But that was what *I* was talking about:
> {
> string name;
> float value;
> }
> which an array or map does not allow. So octave structs are about as similar
> to
> structs as Pink Floyd is similar to Cherry Garcia ice cream.
>
> Any yes, if they're hashmaps then obviously "foo bar" is a valid
> map key, but "a( 3 ).foo bar" is not a valid syntax. Because the space
> between foo and bar is a token separator.
>
> Dima
>
I never meant to use non-quoted non-bareword key as field name.
However, both
1)
"
octave:2> foo = struct
foo =
scalar structure containing the fields:
octave:3> foo."foo bar" = 1
parse error:
syntax error
>>> foo."foo bar" = 1
^
octave:3>
",
2)
"
octave:3> foo = struct
foo =
scalar structure containing the fields:
octave:4> foo.("foo bar") = 1
error: invalid structure field name `foo bar'
octave:4>
"
should work exactly because "foo bar" is a valid hash key.
And, as shown before, the key is accepted through 'setfield':
"
octave:4> foo = struct
foo =
scalar structure containing the fields:
octave:5> setfield(foo, "foo bar", 1)
ans =
scalar structure containing the fields:
foo bar = 1
octave:6>
".
Regards,
Sergei.
- Re: equivalent for C-style init: structname varname[] = {...} ?, (continued)
- Re: equivalent for C-style init: structname varname[] = {...} ?, Salva Ardid, 2012/11/21
- Re: equivalent for C-style init: structname varname[] = {...} ?, Dimitri Maziuk, 2012/11/21
- Re: equivalent for C-style init: structname varname[] = {...} ?, c., 2012/11/21
- Re: equivalent for C-style init: structname varname[] = {...} ?, Sergei Steshenko, 2012/11/20
- Re: equivalent for C-style init: structname varname[] = {...} ?, Ben Abbott, 2012/11/20
- Re: equivalent for C-style init: structname varname[] = {...} ?, Francesco Potortì, 2012/11/21
- Re: equivalent for C-style init: structname varname[] = {...} ?, Dimitri Maziuk, 2012/11/19
- Re: equivalent for C-style init: structname varname[] = {...} ?, Jordi Gutiérrez Hermoso, 2012/11/19
- Re: equivalent for C-style init: structname varname[] = {...} ?,
Sergei Steshenko <=
- Re: equivalent for C-style init: structname varname[] = {...} ?, Dimitri Maziuk, 2012/11/19
- Re: equivalent for C-style init: structname varname[] = {...} ?, Sergei Steshenko, 2012/11/19
- Acknowledge in paper, Ismael Diego Nunez-Riboni, 2012/11/14
- Re: Acknowledge in paper, Juan Pablo Carbajal, 2012/11/14
- Re: Acknowledge in paper, Nicholas Jankowski, 2012/11/14
- Re: Acknowledge in paper, c., 2012/11/14
- Re: Acknowledge in paper, Nicholas Jankowski, 2012/11/14
- Re: Acknowledge in paper, Ismael Diego Nunez-Riboni, 2012/11/14
- Re: Acknowledge in paper, Ismael Diego Nunez-Riboni, 2012/11/14
- Re: Acknowledge in paper, Francesco Potortì, 2012/11/15