Worst ideas/features in programming languages?

russhy russhy at gmail.com
Wed Nov 17 16:28:25 UTC 2021


On Monday, 15 November 2021 at 17:48:35 UTC, H. S. Teoh wrote:
> On Mon, Nov 15, 2021 at 05:25:35PM +0000, russhy via 
> Digitalmars-d wrote: [...]
>> ```D
>> MyAbility ability;
>> 
>> switch (ability)
>> {
>>  case MyAbility.SOMETHING_1: break;
>>  case MyAbility.SOMETHING_2: break;
>>  case MyAbility.SOMETHING_3: break;
>>  case MyAbility.SOMETHING_4: break;
>>  case MyAbility.SOMETHING_5: break;
>> }
>> ```
>> 
>> 
>> What this repetition solves?
> [...]
>
> Why can't you just write:
>
> 	MyAbility ability;
>
> 	switch (ability) with(MyAbility)
> 	{
> 	 case SOMETHING_1: break;
> 	 case SOMETHING_2: break;
> 	 case SOMETHING_3: break;
> 	 case SOMETHING_4: break;
> 	 case SOMETHING_5: break;
> 	}
>
> ?  The `with` keyword was designed specifically for this 
> purpose.
>
>
> T

I don't understand your point, that is exactly what i said, a 
nice use of with

There is a problem here, you don't listen to what i say, 
therefore you don't understand the problem

what about ALL OTHER problems? ;)

MyAbility ability switch ability with MyAbility use Ability

maybe we should have a @with instead of with, that'll solve the 
problem? /s


More information about the Digitalmars-d mailing list