Deprecate case-variables

12345swordy alexanderheistermann at gmail.com
Mon May 15 14:20:21 UTC 2023


On Sunday, 14 May 2023 at 23:11:25 UTC, Walter Bright wrote:
> https://github.com/dlang/dmd/pull/14829
>
> Case variables are:
>
> "The case expressions in ArgumentList are a comma separated 
> list of expressions. Each expression must evaluate to a 
> compile-time value or array, or a **runtime initialized const 
> or immutable variable of integral type**. Each expression must 
> be implicitly convertible to the type of the switch Expression.
>
> Compile-time case values must all be distinct. Const or 
> immutable runtime variables must all have different names. If 
> two case expressions share a value, the first case statement 
> with that value gets control."
>
> https://dlang.org/spec/statement.html#switch-statement
>
> Should we deprecate the case variables?
>
> Pro: for the sake of simplicity, as it is a surprising and 
> presumably little-used feature.
>
> Con: people don't like breaking existing code, and the feature 
> isn't causing any known problems.
>
> I hope we can reach consensus.

Are there better implementation of this in other languages?

-Alex


More information about the Digitalmars-d mailing list