June 26, 2003

"Julio César Carrascal Urquijo" wrote:
> 
> > why not simple assignment operator?
> >
> > myArray = {"red" = "ff0000", // ...
> 
> Since structs are initialized with the ":" operator associative arrays should to
> 
> char[char[]] myArray = [
>     "red": "ff0000",
>     "green": "00ff00",
>     ...
> ]

I would also prefer this syntax. It's intuitive for the user and it should be easiest to implement.

-- 
Helmut Leitner    leitner@hls.via.at
Graz, Austria   www.hls-software.com
June 26, 2003
In article <3EFAB509.52286B89@hls.via.at>, Helmut Leitner says...
>
>
>
>"Julio César Carrascal Urquijo" wrote:
>> 
>> > why not simple assignment operator?
>> >
>> > myArray = {"red" = "ff0000", // ...
>> 
>> Since structs are initialized with the ":" operator associative arrays should to
>> 
>> char[char[]] myArray = [
>>     "red": "ff0000",
>>     "green": "00ff00",
>>     ...
>> ]
>
>I would also prefer this syntax. It's intuitive for the user and it should be easiest to implement.
>
>-- 
>Helmut Leitner    leitner@hls.via.at
>Graz, Austria   www.hls-software.com

Add me to the list of people who like this syntax.

--Benji Smith


June 26, 2003
> I would also prefer this syntax. It's intuitive for the user and it should be easiest to implement.

When you add a new rule to an existing grammar, it doesn't really matter that much which tokens the rule contains, unless they create heavy ambiguities :)

-fg


June 26, 2003
In article <bddhhf$bqj$1@digitaldaemon.com>, Julio César Carrascal Urquijo says...

>Since structs are initialized with the ":" operator associative arrays should to
>
>char[char[]] myArray = [
>    "red": "ff0000",
>    "green": "00ff00",
>    ...
>]
>

In article <bdf708$20ir$1@digitaldaemon.com>, Fabian Giesen says...

>
>> I would also prefer this syntax. It's intuitive for the user and it should be easiest to implement.
>
>When you add a new rule to an existing grammar, it doesn't really matter that much which tokens the rule contains, unless they create heavy ambiguities :)

I disagree.

One could say that it may not matter for the one writing the compiler, but I doubt even that. But carefully choosing the tokens is an extremely important task! A sloppy choice of token early on in the development of a language may not cause any discomfort for a long time, but eventually it will get seriously in the way when new tokens are needed for other things, or when the grammar has to be expanded to encompass new concepts.

I think the above syntax looks nice, and the fact that associative arrays are "sort of" related to structs also speaks for a similar syntax.

But -- I think now is the time for everyone to search for valid reasons why this is not a good choice. If we don't find any, then we can assume this syntax with a good degree of confidence!


June 27, 2003
Julio César Carrascal Urquijo wrote:
> Since structs are initialized with the ":" operator associative arrays
> should to
> 
> char[char[]] myArray = [
>     "red": "ff0000",
>     "green": "00ff00",
>     ...
> ]

Why not adopt prior art?  We are trying to attract C users, after all...

char[char[]] myArray = {
    ["red"] "ff0000",
    ["green"] "00ff00",
    ...

http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

"Designated Initializers

Standard C89 requires the elements of an initializer to appear in a fixed order, the same as the order of the elements in the array or structure being initialized.

In ISO C99 you can give the elements in any order, specifying the array indices or structure field names they apply to, and GNU C allows this as an extension in C89 mode as well. This extension is not implemented in GNU C++.

To specify an array index, write [index] = before the element value. For example,

     int a[6] = { [4] = 29, [2] = 15 };


is equivalent to

     int a[6] = { 0, 0, 15, 0, 29, 0 };"

June 27, 2003
> Why not adopt prior art?  We are trying to attract C users, after all...
>
> char[char[]] myArray = {
>      ["red"] "ff0000",
>      ["green"] "00ff00",
>      ...
>
> http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

Nah, we are trying to attract C/C++ users who are looking for a cleaner language. GCCs syntax is IMHO quite cumbersome (and probably meant not to interfere with existing valid source files).

-fg


June 27, 2003
Fabian Giesen wrote:
>>Why not adopt prior art?  We are trying to attract C users, after
>>all...
>>
>>char[char[]] myArray = {
>>     ["red"] "ff0000",
>>     ["green"] "00ff00",
>>     ...
>>
>>http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
> 
> Nah, we are trying to attract C/C++ users who are looking for a cleaner
> language. GCCs syntax is IMHO quite cumbersome (and probably meant not
> to interfere with existing valid source files).

First of all, my example was not correct; it should be

char[char[]] myArray = {
     ["red"] = "ff0000",
     ["green"] = "00ff00",
     ...

Secondly, it's not GCC's syntax, it's C99 (the four-year-old C standard that most compiler vendors haven't bothered to adopt, except GCC which is moving rather slowly).

June 27, 2003
> First of all, my example was not correct; it should be
>
> char[char[]] myArray = {
>       ["red"] = "ff0000",
>       ["green"] = "00ff00",
>       ...
>
> Secondly, it's not GCC's syntax, it's C99 (the four-year-old C standard that most compiler vendors haven't bothered to adopt, except GCC which is moving rather slowly).

Oh, I thought it was a GCC extension. Anyway, my point still holds - that is hardly intuitive or elegant syntax.

-fg


August 09, 2003
"Julio César Carrascal Urquijo" <adnoctum@phreaker.net> wrote in message news:bddhhf$bqj$1@digitaldaemon.com...
> > why not simple assignment operator?
> >
> > myArray = {"red" = "ff0000", // ...
>
>
> Since structs are initialized with the ":" operator associative arrays should to
>
> char[char[]] myArray = [
>     "red": "ff0000",
>     "green": "00ff00",
>     ...
> ]

I think it's a good syntax too.


August 09, 2003
Got my vote.

Charles

"Walter" <walter@digitalmars.com> wrote in message news:bh38pd$2hhg$1@digitaldaemon.com...
>
> "Julio César Carrascal Urquijo" <adnoctum@phreaker.net> wrote in message news:bddhhf$bqj$1@digitaldaemon.com...
> > > why not simple assignment operator?
> > >
> > > myArray = {"red" = "ff0000", // ...
> >
> >
> > Since structs are initialized with the ":" operator associative arrays should to
> >
> > char[char[]] myArray = [
> >     "red": "ff0000",
> >     "green": "00ff00",
> >     ...
> > ]
>
> I think it's a good syntax too.
>
>