Deprecate case-variables
Meta
jared771 at gmail.com
Tue May 16 17:31:58 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.
Aren't case variables useful for creating jump tables much more
succinctly? It seems like that is a use case that should be
carefully considered.
More information about the Digitalmars-d
mailing list