Jump to page: 1 25  
Page
Thread overview
Remove switch case fallthrough
May 13, 2021
rempas
May 13, 2021
IGotD-
May 13, 2021
rempas
May 13, 2021
IGotD-
May 13, 2021
rempas
May 13, 2021
Imperatorn
May 13, 2021
Adam D. Ruppe
May 13, 2021
Imperatorn
May 14, 2021
Mathias LANG
May 13, 2021
rempas
May 14, 2021
Ogi
May 14, 2021
David Gileadi
May 14, 2021
ag0aep6g
May 14, 2021
David Gileadi
May 15, 2021
Patrick Schluter
May 14, 2021
Dennis
May 21, 2021
Ogi
May 21, 2021
Paul Backus
May 13, 2021
Basile B.
May 13, 2021
rempas
May 13, 2021
rempas
May 14, 2021
Mike Parker
May 14, 2021
rempas
May 14, 2021
Mike Parker
May 14, 2021
Mike Parker
May 14, 2021
Paulo Pinto
May 14, 2021
Mike Parker
May 14, 2021
Patrick Schluter
May 14, 2021
Imperatorn
May 14, 2021
Patrick Schluter
May 14, 2021
Walter Bright
May 13, 2021
Paul Backus
May 13, 2021
IGotD-
May 13, 2021
rempas
May 13, 2021
Basile B.
May 13, 2021

Yeah yeah I know I know, Code that looks like C should have the same behavior to C. I've asked about that and I got the same answer. But come one! We can make an exception on this one! We don't need that in D as we can add more cases.

I really love the work the contributors do with D but IMO is things like that who really stop D from REALLY going forward in the next level. Doing things just for doing them NEVER helped anyone!

May 13, 2021

On Thursday, 13 May 2021 at 13:28:07 UTC, rempas wrote:

>

Yeah yeah I know I know, Code that looks like C should have the same behavior to C. I've asked about that and I got the same answer. But come one! We can make an exception on this one! We don't need that in D as we can add more cases.

I really love the work the contributors do with D but IMO is things like that who really stop D from REALLY going forward in the next level. Doing things just for doing them NEVER helped anyone!

In practice this is possible by just add another keyword. Something like "switch2", "switchb", can't really come up with good name. Then you just have a switch with break as default. What I have against it is that a new type of bugs will occur where the programmers accidentally mix up the two.

May 13, 2021

On Thursday, 13 May 2021 at 13:55:10 UTC, IGotD- wrote:

>

In practice this is possible by just add another keyword. Something like "switch2", "switchb", can't really come up with good name. Then you just have a switch with break as default. What I have against it is that a new type of bugs will occur where the programmers accidentally mix up the two.

Just use a different keyword than "case"? Like "when"?

May 13, 2021
On 5/13/21 9:28 AM, rempas wrote:
> Yeah yeah I know I know, Code that looks like C should have the same behavior to C. I've asked about that and I got the same answer. But come one! We can make an exception on this one! We don't need that in D as we can add more cases.

It's already deprecated, since 2.072. It's also been a warning since 2.054. I'm not sure if this is intended to be removed or not, but removing it today would put it at a 4.5 year deprecation period, and 10 years since it's been a warning.

> 
> I really love the work the contributors do with D but IMO is things like that who really stop D from REALLY going forward in the next level. Doing things just for doing them NEVER helped anyone!

Nobody thinks case fallthrough is good, this is why it's a warning and deprecated.

-Steve
May 13, 2021

On Thursday, 13 May 2021 at 13:28:07 UTC, rempas wrote:

>

Yeah yeah I know I know, Code that looks like C should have the same behavior to C. I've asked about that and I got the same answer. But come one! We can make an exception on this one! We don't need that in D as we can add more cases.

I really love the work the contributors do with D but IMO is things like that who really stop D from REALLY going forward in the next level. Doing things just for doing them NEVER helped anyone!

switch case fallthrough is already considered deprecated. If you use it, the compiler will produce the following warning:

Deprecation: switch case fallthrough - use 'goto case;' if intended

I'm not sure what the process is for turning a deprecation like this into an error (maybe a -preview/-revert switch is needed?), but presumably the intent is for that to happen at some point. In the meantime, you can do it manually by compiling with the -de switch, which tells the compiler to give errors instead of warnings for deprecations.

May 13, 2021

On Thursday, 13 May 2021 at 14:15:39 UTC, Paul Backus wrote:

>

switch case fallthrough is already considered deprecated. If you use it, the compiler will produce the following warning:

Deprecation: switch case fallthrough - use 'goto case;' if intended

I kind of read between the lines and got it to that TS wanted to remove the mandatory break completely. Could be wrong though.

May 13, 2021

On Thursday, 13 May 2021 at 14:22:21 UTC, IGotD- wrote:

>

On Thursday, 13 May 2021 at 14:15:39 UTC, Paul Backus wrote:

>

switch case fallthrough is already considered deprecated. If you use it, the compiler will produce the following warning:

Deprecation: switch case fallthrough - use 'goto case;' if intended

I kind of read between the lines and got it to that TS wanted to remove the mandatory break completely. Could be wrong though.

Yes this is what I mean! There is no reason to have to use break! It is just annoying imo!

May 13, 2021

On Thursday, 13 May 2021 at 14:12:40 UTC, Ola Fosheim Grøstad wrote:

>

On Thursday, 13 May 2021 at 13:55:10 UTC, IGotD- wrote:

>

In practice this is possible by just add another keyword. Something like "switch2", "switchb", can't really come up with good name. Then you just have a switch with break as default. What I have against it is that a new type of bugs will occur where the programmers accidentally mix up the two.

Just use a different keyword than "case"? Like "when"?

Exactly! We can mix things up a little! Or even add a new statement called "match" idk

May 13, 2021
On Thursday, 13 May 2021 at 14:15:15 UTC, Steven Schveighoffer wrote:
> On 5/13/21 9:28 AM, rempas wrote:
>> [...]
>
> It's already deprecated, since 2.072. It's also been a warning since 2.054. I'm not sure if this is intended to be removed or not, but removing it today would put it at a 4.5 year deprecation period, and 10 years since it's been a warning.
>
>> [...]
>
> Nobody thinks case fallthrough is good, this is why it's a warning and deprecated.
>
> -Steve

My mistake for not being clear, like I said to the other comments, I mean that we should not need the "break" anymore.
May 13, 2021

On Thursday, 13 May 2021 at 14:25:53 UTC, rempas wrote:

>

Exactly! We can mix things up a little! Or even add a new statement called "match" idk

That could be possibility to add pattern matching capabilities to D and renew switch that way and add new features as well. D already has some kind of "match" but implemented as a library, maybe D should extend that and bring into the language.

« First   ‹ Prev
1 2 3 4 5