On Tue, 22 Jun 2010 09:17:57 -0400, Adam Ruppe
destructiona...@gmail.com 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:
On Mon, 21 Jun 2010 20:27:32 -0700, Bill Baxter wrote:
On Mon, Jun 21, 2010 at 6:31 PM, Leandro Lucarella l...@llucax.com.ar
wrote:
Bill Baxter, el 21 de junio a las 17:13 me escribiste:
On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella
l...@llucax.com.ar wrote:
goto next case; is a
On Mon, 21 Jun 2010 20:40:14 -0400, Adam Ruppe destructiona...@gmail.com
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
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
On Tue, 22 Jun 2010 02:40:14 +0200, Adam Ruppe destructiona...@gmail.com
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
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
Steven Schveighoffer, el 22 de junio a las 07:26 me escribiste:
On Mon, 21 Jun 2010 20:40:14 -0400, Adam Ruppe
destructiona...@gmail.com 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
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 l...@llucax.com.ar
wrote:
Bill Baxter, el 21 de junio a las 17:13 me escribiste:
On Mon, Jun 21, 2010 at 4:24 PM,
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
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
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_ case statements to be able to
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 less error
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
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
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
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
Andrei Alexandrescu seewebsiteforem...@erdani.org 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
On 06/21/2010 03:46 PM, Sean Kelly wrote:
Andrei Alexandrescuseewebsiteforem...@erdani.org 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
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's more
On 06/21/2010 03:46 PM, Sean Kelly wrote:
Andrei Alexandrescuseewebsiteforem...@erdani.org 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
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
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 control
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! );
}
Having never
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
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, but then
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.
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 are
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 love
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 jmdavisp...@gmail.com wrote:
Andrei Alexandrescu wrote:
[snip]
Andrei
Well, goto case and goto case XXX both already exist. Both get the
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,
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 ?
We can and should do it.
On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella l...@llucax.com.ar 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
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,
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
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 I
Bill Baxter, el 21 de junio a las 17:13 me escribiste:
On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella l...@llucax.com.ar 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
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,
On Mon, Jun 21, 2010 at 6:31 PM, Leandro Lucarella l...@llucax.com.ar wrote:
Bill Baxter, el 21 de junio a las 17:13 me escribiste:
On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella l...@llucax.com.ar
wrote:
goto next case; is a little more verbose but very clear to me :)
Maybe just
On 6/21/10, Andrei Alexandrescu seewebsiteforem...@erdani.org 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
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
On 6/22/10, Don nos...@nospam.com 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
Adam Ruppe wrote:
On 6/21/10, Andrei Alexandrescu seewebsiteforem...@erdani.org 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
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
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
On 06/18/2010 10:08 PM, Vladimir Panteleev wrote:
On Sat, 19 Jun 2010 05:22:47 +0300, Andrei Alexandrescu
seewebsiteforem...@erdani.org 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
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
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
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
seewebsiteforem...@erdani.org wrote:
Walter had no retort to that argument, so he veered into a critique of
the goto case
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 impact TDPL adversely.
Don nos...@nospam.com 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
Dnia 18-06-2010 o 23:11:43 Simen kjaeraas simen.kja...@gmail.com
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.
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
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
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
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 they
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 switch
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 add to
D2
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_.
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 :-)
An
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++; goto case
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
On Fri, 18 Jun 2010 17:03:24 -0400, Don nos...@nospam.com 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
On Fri, 18 Jun 2010 20:23:45 -0400, Jonathan M Davis
jmdavisp...@gmail.com 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
On Sat, 19 Jun 2010 05:22:47 +0300, Andrei Alexandrescu
seewebsiteforem...@erdani.org 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
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 written
two times
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 statements to be able to fall through. It
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
On Fri, 18 Jun 2010 20:17:09 -0700, Jonathan M Davis
jmdavisp...@gmail.com 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
68 matches
Mail list logo