Worst ideas/features in programming languages?

russhy russhy at gmail.com
Mon Nov 15 22:29:38 UTC 2021


On Monday, 15 November 2021 at 21:23:56 UTC, H. S. Teoh wrote:
> On Mon, Nov 15, 2021 at 09:10:51PM +0000, kdevel via 
> Digitalmars-d wrote:
>> On Monday, 15 November 2021 at 17:48:35 UTC, H. S. Teoh wrote: 
>> [...]
>> > 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.
>> 
>> Nice. What about
>> 
>>    import std.stdio;
>>    enum SAB {
>>       a = 1,
>>    }
>>    void main ()
>>    {
>>       with (SAB) if (a == 1) writeln ("true");
>>       with (SAB) void foo () { writeln (a); } // no complaints!
>>       foo(); // Error: undefined identifier `foo`
>>    }
> [...]
>
> That's because `with` introduces a scope.  So you should have 
> written instead:
>
> 	void foo () { with (SAB) writeln (a); }
>
> Or, for that matter:
>
> 	void main ()
> 	{
> 	   with (SAB) {
> 	   	if (a == 1) writeln ("true");
> 	   	void foo () { writeln (a); }
> 	   	foo(); // Now this works
> 	   }
> 	}
>
>
> T

that's not what i am asking

- now you leak SAB scope everywhere
- now you have to indent everything
- there is no differenciation between SAB.a and a variable called 
a


Why make things complicated and bloated when it can be simple?


Also why making me want to want something that is not what i 
asked? it's quite the opposite!


More information about the Digitalmars-d mailing list