Alternative Possibility - Implicit with
Walter Bright
newshound2 at digitalmars.com
Sat Nov 19 18:46:42 UTC 2022
On 11/19/2022 10:26 AM, H. S. Teoh wrote:
>> Implicitly enclose the switch body with a `with (WordLetterOfTheDay)`
>> resulting in:
Upon more reflection, the implicit `with` should only enclose the case
expression, not the other statements in the switch body.
>> Argument lists:
>>
>> Only works if there are no overloads.
>
> There's another use case to address: default parameter declarations.
>
> Current syntax:
>
> enum LongEnumName { abc, def, ghi }
> int myFunc(LongEnumName x = LongEnumName.abc) { ... }
>
> Desired syntax:
>
> enum LongEnumName { abc, def, ghi }
> int myFunc(LongEnumName x = abc) { ... }
>
> i.e., the RHS of a default parameter should be treated just like the
> initialization of an enum variable, there should be an implicit `with`.
Yes, should work the same as other initializations.
More information about the Digitalmars-d
mailing list