February 16, 2002
> > PS: does '12..17' mean '12 <= x <= 17' or '12 <= x < 17' ?
>
> I guess it should follow the syntax for array slices, to prevent confusion. So 12 <= x < 17.

You seriously think that this:

char c;
switch (c)
{
  case ('a'..'{') { printf("lowercase\n"); }
  case ('A'..'[') { printf("uppercase\n"); }
  case ('0'..':') { printf("digit\n"); }
}

is better than this?

char c;
switch (c)
{
  case ('a'..'z') { printf("lowercase\n"); }
  case ('A'..'Z') { printf("uppercase\n"); }
  case ('0'..'9') { printf("digit\n"); }
}

P.S. I had to load up Character Map just to figure out what symbols to put
in the first example, if that clues you in at all.
I suppose however that it could be written like so, but still doesn't appear
very clear:

char c;
switch (c)
{
  case ('a'..'z'+1) { printf("lowercase\n"); }
  case ('A'..'Z'+1) { printf("uppercase\n"); }
  case ('0'..'9'+1) { printf("digit\n"); }
}


February 16, 2002
"Sean L. Palmer" <spalmer@iname.com> wrote in message news:a4kuvk$2fo2$1@digitaldaemon.com...

> You seriously think that this:
>
> char c;
> switch (c)
> {
>   case ('a'..'{') { printf("lowercase\n"); }
>   case ('A'..'[') { printf("uppercase\n"); }
>   case ('0'..':') { printf("digit\n"); }
> }
>
> is better than this?
>
> char c;
> switch (c)
> {
>   case ('a'..'z') { printf("lowercase\n"); }
>   case ('A'..'Z') { printf("uppercase\n"); }
>   case ('0'..'9') { printf("digit\n"); }
> }

No, I don't...

> I suppose however that it could be written like so, but still doesn't
appear
> very clear:
>
> char c;
> switch (c)
> {
>   case ('a'..'z'+1) { printf("lowercase\n"); }
>   case ('A'..'Z'+1) { printf("uppercase\n"); }
>   case ('0'..'9'+1) { printf("digit\n"); }
> }

This is what I think it should look like. Yes, it might look somewhat
strange, but at least a D newbie won't get a headache trying to
understand why case(1 .. 5) works for all 1 <= n <= 5, while
array[1 .. 5] turns out to have length of 4 elements...

...but _personally_, I wouldn't mind if there was such syntax. Simply because I will be aware of it either way. =)


February 16, 2002
Pavel Minayev wrote:

> This is what I think it should look like. Yes, it might look somewhat
> strange, but at least a D newbie won't get a headache trying to
> understand why case(1 .. 5) works for all 1 <= n <= 5, while
> array[1 .. 5] turns out to have length of 4 elements...
>
> ...but _personally_, I wouldn't mind if there was such syntax. Simply because I will be aware of it either way. =)

(twitch)

You just made the best argument yet for end-INclusive array slicing syntax.

--
The Villagers are Online! http://villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]


February 16, 2002
"Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3C6EAF3B.9741F1C3@deming-os.org...

> You just made the best argument yet for end-INclusive array slicing
syntax.

Forget it, I didn't say that... =)

Another idea is to use different syntax:

    case (1, 3 to 5, 7) ...

This way, it differentiates from array slicing op .. enough to avoid confusion, IMO.


February 17, 2002
"d" <s_nudds@hotmail.com> wrote in message news:a4jde2$1q97$1@digitaldaemon.com...
> Using a goto to emulate a fall though is a bad idea.  First it begs abuse where programmers will use goto to jump around multiple times within a
case
> statement.  The result will be more difficult to manage than having a fallthrough as default.
>
> If fallthrough is needed (and I am not convinced that it is),  it would be better to end the case block with a Fallthrough keyword.  This way the programmer is constrained

Agreed.
You only seem to need fallthrough on a very few occasions.
Mostly you just need to break the case.
But couldn't continue be used as the keyword?


--
Stijn
OddesE_XYZ@hotmail.com
http://OddesE.cjb.net
__________________________________________
Remove _XYZ from my address when replying by mail



February 17, 2002
Please, no!!  Let's use break and continue just for loops.  Otherwise it gets confusing.  I'd rather just use goto to implement fallthrough.  Or goto case.  A new "fallthru" keyword would work as well... so long as Walter doesn't mind cluttering up the language with lots of keywords.  ;)

Sean

"OddesE" <OddesE_XYZ@hotmail.com> wrote in message news:a4mveb$dh4$1@digitaldaemon.com...
> "d" <s_nudds@hotmail.com> wrote in message news:a4jde2$1q97$1@digitaldaemon.com...
> > Using a goto to emulate a fall though is a bad idea.  First it begs
abuse
> > where programmers will use goto to jump around multiple times within a
> case
> > statement.  The result will be more difficult to manage than having a fallthrough as default.
> >
> > If fallthrough is needed (and I am not convinced that it is),  it would
be
> > better to end the case block with a Fallthrough keyword.  This way the programmer is constrained
>
> Agreed.
> You only seem to need fallthrough on a very few occasions.
> Mostly you just need to break the case.
> But couldn't continue be used as the keyword?
>
>
> --
> Stijn
> OddesE_XYZ@hotmail.com
> http://OddesE.cjb.net
> __________________________________________
> Remove _XYZ from my address when replying by mail
>
>
>


February 18, 2002
"Pavel Minayev" <evilone@omen.ru> ha scritto nel messaggio news:a4mbd5$63s$1@digitaldaemon.com...
> "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3C6EAF3B.9741F1C3@deming-os.org...
>
> > You just made the best argument yet for end-INclusive array slicing
> syntax.
>
> Forget it, I didn't say that... =)

No, he's right.

v1[] = v2['A'..'Z'+1]

Looks weird. Looks wrong. What a mess...

Ciao




February 18, 2002
"Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:a4qetl$1nbv$1@digitaldaemon.com...

> No, he's right.
>
> v1[] = v2['A'..'Z'+1]
>
> Looks weird. Looks wrong. What a mess...

Just how frequently you index array with chars?
Also v2[0 .. v2.length] looks nice and suites
for(int i = 0; i < v2.length; i++) syntax.




February 18, 2002
Pavel Minayev wrote:

> Another idea is to use different syntax:
>
>     case (1, 3 to 5, 7) ...

Personal opinion:

To my eye, the comma has "higher precedence" than "to".  That is, when I
looked at it, my eyes saw it as
        case ((1,3) to (5,7)) ...
which was confusing to say the least.

I'm not (very much) opposed to forking off a new syntax, I just would
opine that that syntax isn't the one. :)

--
The Villagers are Online! villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]


February 18, 2002
> "OddesE" <OddesE_XYZ@hotmail.com> wrote in message news:a4mveb$dh4$1@digitaldaemon.com...
> > "d" <s_nudds@hotmail.com> wrote in message news:a4jde2$1q97$1@digitaldaemon.com...
> > > Using a goto to emulate a fall though is a bad idea.  First it begs
> abuse
> > > where programmers will use goto to jump around multiple times within a
> > case
> > > statement.  The result will be more difficult to manage than having a fallthrough as default.
> > >
> > > If fallthrough is needed (and I am not convinced that it is),  it
would
> be
> > > better to end the case block with a Fallthrough keyword.  This way the programmer is constrained
> >
> > Agreed.
> > You only seem to need fallthrough on a very few occasions.
> > Mostly you just need to break the case.
> > But couldn't continue be used as the keyword?
> >
> >
> > --
> > Stijn
> > OddesE_XYZ@hotmail.com
> > http://OddesE.cjb.net
> > __________________________________________
> > Remove _XYZ from my address when replying by mail
> >


"Sean L. Palmer" <spalmer@iname.com> wrote in message news:a4o7vb$sam$1@digitaldaemon.com...
> Please, no!!  Let's use break and continue just for loops.  Otherwise it gets confusing.  I'd rather just use goto to implement fallthrough.  Or
goto
> case.  A new "fallthru" keyword would work as well... so long as Walter doesn't mind cluttering up the language with lots of keywords.  ;)
>
> Sean
>


"Juarez Rudsatz" wrote in another message in this thread:
> 2. There are three keywords for switch statement: "switch", "case" and "default". Once the break is out, there are no need of case keyword. And the default keyword could be replaced by another keyword in language:
>
> switch(x){
>     1, 2, 3 : sigle_line_statement();
>     4 : {
>     multi_line_statement_1();
>     multi_line_statement_2();
>     multi_line_statement_3();
>     }
>     else : another_statement();
> }


I think this is a good idea. Leave the switch keyword or change it to
select.
Either way you keep the same amount of keywords. I would recommend
select since it clearly signifies the change in the construct. Ditch
default,
else works just as well. Now we have saved one keyword. The case
keyword really isn't necessary if you make the statements blocks behave like
all other statement blocks in C/C++/D, where you can write one statement
delimited by a semicolon, or a block of multiple statements enclosed in
curly
braces. Now we have saved two keywords. If continue or goto were used
to signfy a jump to another case then we would be at a 'profit' of two
keywords, but even if we added a fallthrough keyword we still would save
keywords, not clutter the language with them.
If you allowed for more than one case on a line, like in the example above,
the fallthrough/continue construct could be ditched altogether for a
more natural looking way of handling multiple cases, while goto would
remain where it is, since it is already available?

Code could look like this:

char c = 'a';

select (c)
{
    'a'..'z':
        printf ("This is a: Lowercase character.\n");
    'A'..'Z':
    {
        printf ("This is a: ");
        printf ("Uppercase character.\n");
    }
    '0'..'9':
    {
        printf ("This is a: ");
        printf ("Decimal digit.\n");
    }
    ';', ',', ':', '.':
        printf ("This is a: Punctuation character.\n");
    else:
        printf ("This is a: Weird character :)\n");
}

I think this is natural looking, easy to understand
and fits in with the D filosophy. Any suggestions?


--
Stijn
OddesE_XYZ@hotmail.com
http://OddesE.cjb.net
__________________________________________
Remove _XYZ from my address when replying by mail