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: Mon, 19 Nov 2012 18:47:59 -0800 (PST)




----- Original Message -----
> From: Dimitri Maziuk <address@hidden>
> To: Sergei Steshenko <address@hidden>
> Cc: "address@hidden" <address@hidden>
> Sent: Tuesday, November 20, 2012 4:31 AM
> Subject: Re: equivalent for C-style init: structname varname[] = {...} ?
> 
> On 11/19/2012 07:26 PM, Sergei Steshenko wrote:
> 
>>  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':
> 
> I suspect it's because nobody does it. There may be some reason why
> lexer won't easily tokenize foo."foo bar" into foo, dot, and 
> "foo bar",
> but I can't think of one right now.
> 
> -- 
> Dimitri Maziuk
> Programmer/sysadmin
> BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu
>

At least, foo.("foo bar") should _not_ be a problem since foo.("bar") _is_ 
recognized:

"
octave:1> foo = struct
foo =

  scalar structure containing the fields:


octave:2> foo.("bar")  = 1
foo =

  scalar structure containing the fields:

    bar =  1
".

I mean, string expression in parenthesis ('("bar")') is recognized, so there 
shouldn't be a reason for different strings to be treated differently when the 
strings are used as hash keys.


Regards,
  Sergei.


octave:3>   



reply via email to

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