June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedence rules? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | 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
> horribly painful in many cases if they couldn't. Now, requiring a separate
> statement like fallthrough or somesuch instead of break might not be a bad
> idea, but requiring that each case end with a break would seriously restrict
> the usefulness of switch statements.
>
> - Jonathan M Davis
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:
error();
break;
}
| |||
June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedence rules? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Vladimir Panteleev | On 06/18/2010 10:08 PM, Vladimir Panteleev wrote:
> On Sat, 19 Jun 2010 05:22:47 +0300, Andrei Alexandrescu
> <SeeWebsiteForEmail@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 with goto you'd
>> need to update the goto target. However, it can be argued that
>> logically you want to continue processing at some specific logical
>> point, not to blindly fall through to whatever the heck code happens
>> to be there.
>
> Well, if "goto case XXX" is unmaintainable, how about some combination
> of existing keywords? For example, "continue switch;".
>
> -- Best regards,
> Vladimir mailto:vladimir@thecybershadow.net
Clever!
Andrei
| |||
June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedence | ||||
|---|---|---|---|---|
| ||||
Posted in reply to KennyTM~ | 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:
> error();
> break;
> }
I didn't know this, this is a hidden D feature. So it's just a matter of D forbidding the cases that miss an explicit return, goto, or break, assert(0), exit(), and similar.
As for the multiple returns in a function this needs a bit of care because this is acceptable:
switch (x) {
case 0:
if (y)
goto case;
else
return x;
default:
break;
}
Bye,
bearophile
| |||
June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedence rules? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 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 (a < b < c) { ... } > > although it's compilable code in C. The same strategy could be used for combinations of badly-prioritized operators: the language could just require the user to add parens. > > > Andrei | |||
June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedence rules? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Don | 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 first. He's the BDFL!
Andrei
| |||
June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedence rules? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 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 to make sure Walter approves first. He's the BDFL!
>
> Andrei
BDFL = ?
Some lame acronym letter tries:
B = benevolent
D = dictator
F = <nullable/>
L = language
| |||
June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedencerules? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Justin Johansson | Hello Justin, >> > BDFL = ? > > Some lame acronym letter tries: > B = benevolent > D = dictator F = for ? > L = language -- ... <IXOYE>< | |||
June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedencerules? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to BCS | On 06/19/2010 10:17 AM, BCS wrote: > Hello Justin, > > >>> >> BDFL = ? >> >> Some lame acronym letter tries: >> B = benevolent >> D = dictator > > F = for ? > >> L = language http://en.wikipedia.org/wiki/Benevolent_Dictator_For_Life Andrei | |||
June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedencerules? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Tomek Sowiński | Hello Tomek, > Dnia 18-06-2010 o 23:11:43 Simen kjaeraas <simen.kjaras@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. > vote++; > Tomek > -- ... <IXOYE>< | |||
June 19, 2010 Re: Is there ANY chance we can fix the bitwise operator precedence rules? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Justin Johansson | 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. > >> > >>Excellent! I'll make a patch for it when I have time. > > > >You may want to make sure Walter approves first. He's the BDFL! > > > >Andrei > > BDFL = ? > > Some lame acronym letter tries: > B = benevolent > D = dictator For Life Taken from Python. http://en.wikipedia.org/wiki/Benevolent_Dictator_For_Life I don't think Walter is a BDFL, though. He is more a OMD (orchestra-man dictator), as he do everything by himself and nobody could ever do anything else, he doesn't "resolve disputes or competing arguments within the community", he just do what he wants (except from Phobos now, fortunately). -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Hay manos capaces de fabricar herramientas con las que se hacen máquinas para hacer ordenadores que a su vez diseñan máquinas que hacen herramientas para que las use la mano | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply