Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-23 Thread Justin Spahr-Summers
On Tue, 22 Jun 2010 09:17:57 -0400, Adam Ruppe wrote: > > What you guys are saying makes enough sense. switch will always be a > series of labels and jumps in my mind, but I can deal with this. > > One note that I think is the main reason people find fallthrough > confusing: they hit tab once t

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Jeff Nowakowski
On 06/22/2010 08:39 AM, Don wrote: I think you misunderstood. I was arguing that there is no association between 'goto' and loops. People who use goto, use it for error handling, not for looping. I was by no means advocating the use of goto for error handling! Oh good :) The looping part wasn'

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Adam Ruppe
What you guys are saying makes enough sense. switch will always be a series of labels and jumps in my mind, but I can deal with this. One note that I think is the main reason people find fallthrough confusing: they hit tab once too many times. switch(a) { case 10: case 20: // obvious fall

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Leandro Lucarella
Steven Schveighoffer, el 22 de junio a las 07:26 me escribiste: > On Mon, 21 Jun 2010 20:40:14 -0400, Adam Ruppe > wrote: > > >What's the point of a switch without implicit fallthrough? > > Maintenance. Using if statements instead of switch, you have to > repeat the value to test for each of th

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Leandro Lucarella
Lars T. Kyllingstad, el 22 de junio a las 09:14 me escribiste: > On Mon, 21 Jun 2010 20:27:32 -0700, Bill Baxter wrote: > > > On Mon, Jun 21, 2010 at 6:31 PM, Leandro Lucarella > > wrote: > >> Bill Baxter, el 21 de junio a las 17:13 me escribiste: > >>> On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lu

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Don
Jeff Nowakowski wrote: On 06/22/2010 12:06 AM, Don wrote: Finally, goto is ugly and continue is strongly associated with looping. ? It's most commonly used in error handling. But, fallthrough actually is a goto. Do I really have to argue that goto is mostly deprecated, and has been for deca

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Don
Steven Schveighoffer wrote: On Mon, 21 Jun 2010 20:40:14 -0400, Adam Ruppe wrote: What's the point of a switch without implicit fallthrough? Maintenance. Using if statements instead of switch, you have to repeat the value to test for each of the cases. If you want to change the value be

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Simen kjaeraas
On Tue, 22 Jun 2010 02:40:14 +0200, Adam Ruppe wrote: What's the point of a switch without implicit fallthrough? If you take that away, it offers nothing that if/elseif doesn't. (Aside from not retyping the switch(stuff here), which you can bring into a function anyway, so whoop-de-doo. And I

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Jeff Nowakowski
On 06/22/2010 12:06 AM, Don wrote: Finally, goto is ugly and continue is strongly associated with looping. ? It's most commonly used in error handling. But, fallthrough actually is a goto. Do I really have to argue that goto is mostly deprecated, and has been for decades? Lots of programming

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Steven Schveighoffer
On Mon, 21 Jun 2010 20:40:14 -0400, Adam Ruppe wrote: What's the point of a switch without implicit fallthrough? Maintenance. Using if statements instead of switch, you have to repeat the value to test for each of the cases. If you want to change the value being tested, it's one chang

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Lars T. Kyllingstad
On Mon, 21 Jun 2010 20:27:32 -0700, Bill Baxter wrote: > On Mon, Jun 21, 2010 at 6:31 PM, Leandro Lucarella > wrote: >> Bill Baxter, el 21 de junio a las 17:13 me escribiste: >>> On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella >>> wrote: >>> > goto next case; is a little more verbose but very

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Don
Adam Ruppe wrote: On 6/21/10, Andrei Alexandrescu wrote: Then why are people using switch and next to nobody uses fall through (provably including Walter, who thinks is using fall through "all the time")? Do you have some stats from the phobos and dmd source? I ran a crude text pattern progra

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Adam Ruppe
On 6/22/10, Don wrote: > Did you consider situations where the last thing before the case is > actually a 'goto' ? Walter does that a lot. Yeah, me too. I counted them the same as break (and continue, return, and throw). Here's my source. I know it has some false negatives and some false positiv

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Jonathan M Davis
BCS wrote: > Hello Jonathan, > >> "goto case" does seem a bit silly, but I think that it's clearer and >> less error prone for anyone who understands "goto case." > > Say I have some code with a fall through. If I use the goto case X; > version, it allows the cases to be freely reordered. OTOH i

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Don
Jeff Nowakowski wrote: On 06/21/2010 05:11 PM, Jonathan M Davis wrote: Having something like "fallthrough" or "goto next case" would of course be even clearer, but those would require new keywords. I think "fallthrough" would be a perfect keyword to add here. C programmers will immediately r

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Adam Ruppe
On 6/21/10, Andrei Alexandrescu wrote: > Then why are people using switch and next to nobody uses fall through > (provably including Walter, who thinks is using fall through "all the > time")? Do you have some stats from the phobos and dmd source? I ran a crude text pattern program, and it said a

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Bill Baxter
On Mon, Jun 21, 2010 at 6:31 PM, Leandro Lucarella wrote: > Bill Baxter, el 21 de junio a las 17:13 me escribiste: >> On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella >> wrote: >> > goto next case; is a little more verbose but very clear to me :) >> > >> > Maybe just next case; is a shorter al

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread BCS
Hello Jonathan, "goto case" does seem a bit silly, but I think that it's clearer and less error prone for anyone who understands "goto case." Say I have some code with a fall through. If I use the goto case X; version, it allows the cases to be freely reordered. OTOH if I use the other option

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Leandro Lucarella
Bill Baxter, el 21 de junio a las 17:13 me escribiste: > On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella wrote: > > goto next case; is a little more verbose but very clear to me :) > > > > Maybe just next case; is a shorter alternative... > > That would be great if "next" were a D keyword. Bu

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-21 Thread Leandro Lucarella
Jonathan M Davis, el 21 de junio a las 17:03 me escribiste: > bearophile wrote: > > > Andrei Alexandrescu: > >> The problem is, if Walter sees us bickering too much, he'll use that as > >> pretext to veto out any improvement. > > > > You are wrong, Walter is an adult able to understand discussion

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Leandro Lucarella
Adam Ruppe, el 21 de junio a las 20:40 me escribiste: > What's the point of a switch without implicit fallthrough? If you take > that away, it offers nothing that if/elseif doesn't. (Aside from not > retyping the switch(stuff here), which you can bring into a function > anyway, so whoop-de-doo. And

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 07:40 PM, Adam Ruppe wrote: What's the point of a switch without implicit fallthrough? If you take that away, it offers nothing that if/elseif doesn't. (Aside from not retyping the switch(stuff here), which you can bring into a function anyway, so whoop-de-doo. And I guess some perf

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Adam Ruppe
What's the point of a switch without implicit fallthrough? If you take that away, it offers nothing that if/elseif doesn't. (Aside from not retyping the switch(stuff here), which you can bring into a function anyway, so whoop-de-doo. And I guess some performance boosts in rearranging the cases, but

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Bill Baxter
On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella wrote: > goto next case; is a little more verbose but very clear to me :) > > Maybe just next case; is a shorter alternative... That would be great if "next" were a D keyword. But I don't think you're going to get Walter to add a keyword just fo

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Leandro Lucarella
Andrei Alexandrescu, el 21 de junio a las 15:31 me escribiste: > On 06/21/2010 03:08 PM, Don wrote: > >Andrei Alexandrescu wrote: > >>On 06/19/2010 06:58 AM, Don wrote: > >>>Andrei Alexandrescu wrote: > Don wrote: > [snip] > >Or is too late to break backwards compatibility with B ? > >>

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Leandro Lucarella
Andrei Alexandrescu, el 21 de junio a las 15:25 me escribiste: > On 06/21/2010 01:27 PM, Sean Kelly wrote: > >Jonathan M Davis Wrote: > >> > >>In any case, that means that it could be made required to have a control > >>statement at the end of a case block without having to specify a specific > >>d

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 06:56 PM, Jonathan M Davis wrote: Andrei Alexandrescu wrote: [snip] Andrei Well, "goto case" and "goto case XXX" both already exist. Both get the job done. So, regardless of which would be better for fallthrough, we can choose to use whichever we want in our code. As it stands

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-21 Thread Jonathan M Davis
bearophile wrote: > Andrei Alexandrescu: >> The problem is, if Walter sees us bickering too much, he'll use that as >> pretext to veto out any improvement. > > You are wrong, Walter is an adult able to understand discussions, not a > capricious dictator :-) Syntax and other things require discuss

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Bill Baxter
Did anyone suggest "continue case" instead of "continue switch"? That sounds less ambiguous to me. --bb On Mon, Jun 21, 2010 at 4:56 PM, Jonathan M Davis wrote: > Andrei Alexandrescu wrote: > > [snip] >> >> >> Andrei > > Well, "goto case" and "goto case XXX" both already exist. Both get the job

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-21 Thread bearophile
Andrei Alexandrescu: > The problem is, if Walter sees us bickering too much, he'll use that as > pretext to veto out any improvement. You are wrong, Walter is an adult able to understand discussions, not a capricious dictator :-) Syntax and other things require discussions, sometimes even longis

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Jonathan M Davis
Andrei Alexandrescu wrote: [snip] > > > Andrei Well, "goto case" and "goto case XXX" both already exist. Both get the job done. So, regardless of which would be better for fallthrough, we can choose to use whichever we want in our code. As it stands, it becomes a matter of preference. I'd lo

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Jeff Nowakowski
On 06/21/2010 05:11 PM, Jonathan M Davis wrote: Having something like "fallthrough" or "goto next case" would of course be even clearer, but those would require new keywords. I think "fallthrough" would be a perfect keyword to add here. C programmers will immediately recognize it. Switch/case

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 06:01 PM, Jonathan M Davis wrote: Andrei Alexandrescu wrote: After Sean's example, goto case XXX is my fave for fallthrough. I don't like unlabeled "goto case" to mean fall through, it's one of those "need to look in the manual" features. goto case XXX is generalized fall through.

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Jonathan M Davis
Andrei Alexandrescu wrote: > > After Sean's example, goto case XXX is my fave for fallthrough. I don't > like unlabeled "goto case" to mean fall through, it's one of those "need > to look in the manual" features. goto case XXX is generalized fall > through. > > Andrei Well, it definitely works,

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 04:15 PM, Don wrote: Jonathan M Davis wrote: Sean Kelly wrote: Jonathan M Davis Wrote: In any case, that means that it could be made required to have a control statement at the end of a case block without having to specify a specific destination for fallthrough - though I'd pref

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Sean Kelly
Jonathan M Davis Wrote: > Sean Kelly wrote: > > > > It's a small thing, but I think "continue switch" could be misleading. > > Consider this: > > > > switch (getState()) { > > case X: > > setState(Z); > > continue switch; > > case Y: > > break; > > case Z: > > writeln( "done!" )

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-21 Thread Sean Kelly
Andrei Alexandrescu Wrote: > On 06/21/2010 01:27 PM, Sean Kelly wrote: > > Jonathan M Davis Wrote: > >> > >> In any case, that means that it could be made required to have a control > >> statement at the end of a case block without having to specify a specific > >> destination for fallthrough - th

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Jonathan M Davis
Don wrote: > > But 'goto case XXX' is an extremely rarely encountered construct, that > screams 'Examine this code closely'. So I don't think it needs extra > error checking. Oh, I don't think that it's a big issue. We have "goto case XXX" and "goto case," so we could use them to enforce flow co

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Don
Jonathan M Davis wrote: Sean Kelly wrote: Jonathan M Davis Wrote: In any case, that means that it could be made required to have a control statement at the end of a case block without having to specify a specific destination for fallthrough - though I'd prefer "continue switch" over "goto case

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 03:46 PM, Sean Kelly wrote: Andrei Alexandrescu wrote: On 06/21/2010 01:27 PM, Sean Kelly wrote: Jonathan M Davis Wrote: In any case, that means that it could be made required to have a control statement at the end of a case block without having to specify a specific destinatio

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Jonathan M Davis
Sean Kelly wrote: > Jonathan M Davis Wrote: >> >> In any case, that means that it could be made required to have a control >> statement at the end of a case block without having to specify a specific >> destination for fallthrough - though I'd prefer "continue switch" over >> "goto case" since it

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Ellery Newcomer
On 06/21/2010 03:46 PM, Sean Kelly wrote: Andrei Alexandrescu wrote: On 06/21/2010 01:27 PM, Sean Kelly wrote: Jonathan M Davis Wrote: In any case, that means that it could be made required to have a control statement at the end of a case block without having to specify a specific destinatio

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Sean Kelly
Andrei Alexandrescu wrote: > On 06/21/2010 01:27 PM, Sean Kelly wrote: >> Jonathan M Davis Wrote: >>> >>> In any case, that means that it could be made required to have a > > > control >>> statement at the end of a case block without having to specify a > > > specific >>> destination for fallthro

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-21 Thread bearophile
Don: > I patched my DMD. Quite successful. It caught 8 bugs in Phobos, in code > written by at least 4 different people. I think everyone gets stung by > that B. Thank you Don. Bye, bearophile

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 03:08 PM, Don wrote: Andrei Alexandrescu wrote: On 06/19/2010 06:58 AM, Don wrote: Andrei Alexandrescu wrote: Don wrote: [snip] Or is too late to break backwards compatibility with B ? We can and should do it. It won't impact TDPL adversely. Excellent! I'll make a patch for

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Andrei Alexandrescu
On 06/21/2010 01:27 PM, Sean Kelly wrote: Jonathan M Davis Wrote: In any case, that means that it could be made required to have a control statement at the end of a case block without having to specify a specific destination for fallthrough - though I'd prefer "continue switch" over "goto case"

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Don
Andrei Alexandrescu wrote: On 06/19/2010 06:58 AM, Don wrote: Andrei Alexandrescu wrote: Don wrote: [snip] Or is too late to break backwards compatibility with B ? We can and should do it. It won't impact TDPL adversely. Excellent! I'll make a patch for it when I have time. Walter just g

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread bearophile
Sean Kelly: > Having never encountered D before, what would be your interpretation of this > code? Unfortunately the "continue case;" syntax looks about equally unintuitive to me :-( Bye, bearophile

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Sean Kelly
Jonathan M Davis Wrote: > > In any case, that means that it could be made required to have a control > statement at the end of a case block without having to specify a specific > destination for fallthrough - though I'd prefer "continue switch" over "goto > case" since it's more explicit and le

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-21 Thread bearophile
KennyTM~: > That is just C#'s switch syntax. Some of the C# designers are people with a long experience in implementing (Pascal-like) programming languages. Convergent evolution is a way to confirm my idea was good, then :-) >And I don't see how the current switch syntax is "hairy".< Even if

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-21 Thread Jonathan M Davis
KennyTM~ wrote: > On Jun 19, 10 07:17, Jonathan M Davis wrote: >> bearophile wrote: >> >>> 2) switch cases that don't end with goto or break: >>> >>> void main() { >>> int x, y; >>> switch (x) { >>> case 0: y++; >>> default: y--; >>> } >>> } >> >> I, for one, _want

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-21 Thread KennyTM~
On Jun 21, 10 17:52, bearophile wrote: Andrei: The intent is to only require a control flow transfer if there is at least one statement after the label.< The current switch syntax is already very hairy (even lot of people on this newsgroup are ignorant about some parts of it!) and it contai

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-21 Thread Don
bearophile wrote: Andrei: The intent is to only require a control flow transfer if there is at least one statement after the label.< The current switch syntax is already very hairy (even lot of people on this newsgroup are ignorant about some parts of it!) and it contains one or more speci

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-21 Thread bearophile
Andrei: >The intent is to only require a control flow transfer if there is at least one >statement after the label.< The current switch syntax is already very hairy (even lot of people on this newsgroup are ignorant about some parts of it!) and it contains one or more special cases. So I sugge

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread BCS
Hello Andrei, On 06/20/2010 09:00 PM, bearophile wrote: Michel Fortin: But what about the "case 1: ... case 10:" syntax? switch (x) { case 1: .. case 10: case 22: .. case 32: case 52, 64: doSomething(); break; default: whatever(); break; } Sorry, in my first answer I have a bit partially m

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread Andrei Alexandrescu
On 06/20/2010 09:00 PM, bearophile wrote: Michel Fortin: But what about the "case 1: ... case 10:" syntax? switch (x) { case 1: .. case 10: case 22: .. case 32: case 52, 64: doSomething(); br

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Michel Fortin: > But what about the "case 1: ... case 10:" syntax? > > switch (x) { > case 1: .. case 10: > case 22: .. case 32: > case 52, 64: > doSomething(); > break; > default: >

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Michel Fortin: > But what about the "case 1: ... case 10:" syntax? You are right, I think we have to make an exception on this then, and consider that range a single entity. (You have just found an example why a conceptually messed up syntax (like that ranged one) always comes to bite us in the

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread Michel Fortin
On 2010-06-20 19:42:49 -0400, bearophile said: I think he means every case. Sometimes a small change, even if seems a little less handy, is useful. Can't you write code like this, that also looks better to me? import std.stdio: writeln; void doSomething() { writeln("doSomething"); } void wha

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Sean Kelly: > As long as there's a way to enumerate case labels I don't really care what > the syntax is. That would be more than fine with me. Good (note that the code I have written is already correct D syntax) :-) Bye, bearophile

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread Sean Kelly
bearophile Wrote: > Sean Kelly: > > You mean every label that is followed by a statement, correct? This is a > > common idiom that I wouldn't want to change: > > > > switch (x) { > > case 1: case 2: case 3: case 4: > > doSomething(); > > break; > > default: > > whatever(); > > } >

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Sean Kelly: > You mean every label that is followed by a statement, correct? This is a > common idiom that I wouldn't want to change: > > switch (x) { > case 1: case 2: case 3: case 4: > doSomething(); > break; > default: > whatever(); > } I think he means every case. Sometimes a sm

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread Sean Kelly
Andrei Alexandrescu Wrote: > On 06/19/2010 06:58 AM, Don wrote: > > Andrei Alexandrescu wrote: > >> Don wrote: > >> [snip] > >>> Or is too late to break backwards compatibility with B ? > >> > >> We can and should do it. It won't impact TDPL adversely. > > > > Excellent! I'll make a patch for it w

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Andrei Alexandrescu: > He also agreed to give more thought to the restriction of forcing every > swich label to be ended with a control flow transfer statement. I hope Walter will express his positive vote about this other little C syntax detail, automatic joining of adjacent strings: http://d.p

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-20 Thread bearophile
Andrei Alexandrescu: > Walter just gave the green light, so Don - it's up to you. Probably our awesome Don will be able to do it, sooner or later :-) > He also agreed to give more thought to the restriction of forcing every > swich label to be ended with a control flow transfer statement. Good

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-20 Thread Andrei Alexandrescu
On 06/19/2010 06:58 AM, Don wrote: Andrei Alexandrescu wrote: Don wrote: [snip] Or is too late to break backwards compatibility with B ? We can and should do it. It won't impact TDPL adversely. Excellent! I'll make a patch for it when I have time. Walter just gave the green light, so Don

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-19 Thread KennyTM~
On Jun 19, 10 17:56, bearophile wrote: KennyTM~: This "fallthrough" statement already exists. switch (x) { case 0: do_something(); goto case; case 1: do_more_thing(); goto case; case 2: done(); br

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-19 Thread Leandro Lucarella
Andrei Alexandrescu, el 19 de junio a las 03:15 me escribiste: > On 06/18/2010 10:08 PM, Vladimir Panteleev wrote: > >On Sat, 19 Jun 2010 05:22:47 +0300, Andrei Alexandrescu > > wrote: > > > >>Walter had no retort to that argument, so he veered into a critique of > >>the goto case XXX solution sayi

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-19 Thread Leandro Lucarella
Justin Johansson, el 19 de junio a las 23:24 me escribiste: > Andrei Alexandrescu wrote: > >On 06/19/2010 06:58 AM, Don wrote: > >>Andrei Alexandrescu wrote: > >>>Don wrote: > >>>[snip] > Or is too late to break backwards compatibility with B ? > >>> > >>>We can and should do it. It won't impac

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-19 Thread Andrej Mitrovic
That's funny, just yesterday I was reading about lazy evaluation in D from this page: http://www.digitalmars.com/d/2.0/lazy-evaluation.html And then I noticed we could make our own switch-like structures. (The code below the string "More complex user defined control structures") Purists will,

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-19 Thread Justin Johansson
Andrei Alexandrescu wrote: On 06/19/2010 06:58 AM, Don wrote: Andrei Alexandrescu wrote: Don wrote: [snip] Or is too late to break backwards compatibility with B ? We can and should do it. It won't impact TDPL adversely. Excellent! I'll make a patch for it when I have time. You may want

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-19 Thread Andrei Alexandrescu
On 06/19/2010 06:58 AM, Don wrote: Andrei Alexandrescu wrote: Don wrote: [snip] Or is too late to break backwards compatibility with B ? We can and should do it. It won't impact TDPL adversely. Excellent! I'll make a patch for it when I have time. You may want to make sure Walter approves

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-19 Thread Don
Andrei Alexandrescu wrote: Don wrote: [snip] Or is too late to break backwards compatibility with B ? We can and should do it. It won't impact TDPL adversely. Excellent! I'll make a patch for it when I have time. A perhaps little known thing is that D doesn't allow this: int a, b, c; if

Re: Is there ANY chance we can fix the bitwise operator precedence

2010-06-19 Thread bearophile
KennyTM~: > This "fallthrough" statement already exists. > > switch (x) { > case 0: > do_something(); > goto case; > case 1: > do_more_thing(); > goto case; > case 2: > done(); > break; > default: >

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-19 Thread Andrei Alexandrescu
On 06/18/2010 10:08 PM, Vladimir Panteleev wrote: On Sat, 19 Jun 2010 05:22:47 +0300, Andrei Alexandrescu wrote: Walter had no retort to that argument, so he veered into a critique of the goto case XXX solution saying it's unmaintainable: when you moving code around you want to keep on falling

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread KennyTM~
On Jun 19, 10 07:17, Jonathan M Davis wrote: bearophile wrote: 2) switch cases that don't end with goto or break: void main() { int x, y; switch (x) { case 0: y++; default: y--; } } I, for one, _want_ case statements to be able to fall through. It would be ho

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Justin Spahr-Summers
On Fri, 18 Jun 2010 20:17:09 -0700, Jonathan M Davis wrote: > >> I, for one, _want_ case statements to be able to fall through. It would > >> be horribly painful in many cases if they couldn't. Now, requiring a > >> separate statement like fallthrough or somesuch instead of break might > >> not b

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Jonathan M Davis
Vladimir Panteleev wrote: > Well, if "goto case XXX" is unmaintainable, how about some combination of > existing keywords? For example, "continue switch;". Ooh. I like that. I don't know how well that would work with the grammar, but it's fairly aesthetically pleasing and definitely more mainta

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Jonathan M Davis
Andrei Alexandrescu wrote: > Jonathan M Davis wrote: >> bearophile wrote: >> >>> 2) switch cases that don't end with goto or break: >>> >>> void main() { >>> int x, y; >>> switch (x) { >>> case 0: y++; >>> default: y--; >>> } >>> } >> >> I, for one, _want_ case statem

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Jonathan M Davis
bearophile wrote: > Jonathan M Davis: > >>Well, I would pount out that you mentioning it more or less reopens the >>discussion,< > > You are right, but probably Walter will not sue me for reopening an old > thread ;-) > > > In the things you are saying you seem to ignore the "goto" I have writ

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Vladimir Panteleev
On Sat, 19 Jun 2010 05:22:47 +0300, Andrei Alexandrescu wrote: Walter had no retort to that argument, so he veered into a critique of the goto case XXX solution saying it's unmaintainable: when you moving code around you want to keep on falling through but with goto you'd need to update

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Robert Jacques
On Fri, 18 Jun 2010 20:23:45 -0400, Jonathan M Davis wrote: bearophile wrote: Jonathan M Davis: but requiring that each case end with a break would seriously restrict the usefulness of switch statements. Time ago there was a long thread about this topic (and in the meantime Walter has ad

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Robert Jacques
On Fri, 18 Jun 2010 17:03:24 -0400, Don wrote: In the comments for bug 4077, "Bugs caused by bitwise operator precedence" it was asked why C gave & with lower precedence than ==, when it is unintuitive and a frequent source of bugs. I was quite shocked to find that the reason is backwards

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Andrei Alexandrescu
Jonathan M Davis wrote: bearophile wrote: 2) switch cases that don't end with goto or break: void main() { int x, y; switch (x) { case 0: y++; default: y--; } } I, for one, _want_ case statements to be able to fall through. It would be horribly painful in many ca

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread bearophile
> As this (this is D syntax that you can already use): > > void main() { > int x, y; > switch (x) { > case 0: y++; goto case 1; > case 1: y++; > default: > } > } Sorry, I meant something like: void main() { int x, y; switch (x) { case 0: y++; g

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread bearophile
Jonathan M Davis: >Well, I would pount out that you mentioning it more or less reopens the >discussion,< You are right, but probably Walter will not sue me for reopening an old thread ;-) In the things you are saying you seem to ignore the "goto" I have written two times in my answers :-)

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Jonathan M Davis
Jonathan M Davis wrote: ... > the simplest answer would be if you have > multiple values for the variable that your switching on which should all > be using the same kind. ... Yikes, that should be "using the same _code_."

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Jonathan M Davis
bearophile wrote: > Jonathan M Davis: >> but requiring that each case end with a break would seriously restrict >> the usefulness of switch statements. > > Time ago there was a long thread about this topic (and in the meantime > Walter has added the "static switch" that burns the fat chance to ad

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread bearophile
Jonathan M Davis: > but requiring that each case end with a break would seriously restrict > the usefulness of switch statements. Time ago there was a long thread about this topic (and in the meantime Walter has added the "static switch" that burns the fat chance to add to D2 a second safer swi

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Jonathan M Davis
bearophile wrote: > 2) switch cases that don't end with goto or break: > > void main() { > int x, y; > switch (x) { > case 0: y++; > default: y--; > } > } I, for one, _want_ case statements to be able to fall through. It would be horribly painful in many cases if the

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread bearophile
bearophile: > >>> 1 < 5 < 10 > True It's especially useful when the value in the middle is the result of some function call: if 1 < foo(5) < 10: ... In D you have to use a temporary variable: auto aux = foo(5); if (1 < aux && aux < 10) { ... Bye, bearophile

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread bearophile
Don: > Tragic. Can we end this madness? > Could we give & | ^ the same precedence as ==, making > (a & mask == b) an error, just as (a < b == c) is rejected? > That way we could lay this common bug to rest. You can change the dmd compiler (even D1, if you want) applying this change and create a

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Andrei Alexandrescu
Don wrote: [snip] Or is too late to break backwards compatibility with B ? We can and should do it. It won't impact TDPL adversely. A perhaps little known thing is that D doesn't allow this: int a, b, c; if (a < b < c) { ... } although it's compilable code in C. The same strategy could be us

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Tomek Sowiński
Dnia 18-06-2010 o 23:11:43 Simen kjaeraas napisał(a): But yes, end the madness. I fear Walter will only do it if it provably breaks no code, though. if (a==b & c) would be flagged as error. If it breaks loudly, that's ok. Besides, it's not much used anyway. Ban it. Tomek

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Simen kjaeraas
Don wrote: I was quite shocked to find that the reason is backwards compatibility with the B programming language. Surely it is important that all B code ported to D compiles correctly? :p But yes, end the madness. I fear Walter will only do it if it provably breaks no code, though. I just

Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-18 Thread Don
In the comments for bug 4077, "Bugs caused by bitwise operator precedence" it was asked why C gave & with lower precedence than ==, when it is unintuitive and a frequent source of bugs. I was quite shocked to find that the reason is backwards compatibility with the B programming language. De