Worst ideas/features in programming languages?

Steven Schveighoffer schveiguy at gmail.com
Mon Nov 15 14:19:00 UTC 2021


On 11/15/21 7:41 AM, Timon Gehr wrote:
> On 15.11.21 10:29, Imperatorn wrote:
>> On Monday, 15 November 2021 at 00:49:17 UTC, tsbockman wrote:
>>> On Sunday, 14 November 2021 at 23:51:00 UTC, Imperatorn wrote:
>>>> On Sunday, 14 November 2021 at 21:13:59 UTC, Dr Machine Code wrote:
>>>>> On Tuesday, 12 October 2021 at 18:59:29 UTC, Imperatorn wrote:
>>>>>> foreach_reverse - worst "feature" mankind has produced
>>>>>
>>>>> why is it that bad? lol
>>>>
>>>> It's just so ugly 😅
>>>
>>> The keyword isn't pretty, but it's useful, easy to understand, and 
>>> actually works correctly.
>>>
>>> I'm sure you can think of something worse if you really try...
>>
>> Well, obviously :)
>>
>> It was more of a joke, but it's still pretty cringe to see it
> 
> The reason it exists is that reverse iteration over unsigned types is 
> notoriously error prone. I think it's pretty nice to have this built in, 
> knowing that it will be directly transformed into a simple for loop even 
> in debug builds. It also allows easily reversing the order of iteration 
> of any foreach loop, no matter which form. In particular, there is 
> `static foreach_reverse`.

Although it's fallen mostly out of style, the reason I hated 
`foreach_reverse` is because it used to be applicable to delegate 
iteration, but just iterates forward (I've just checked and it's 
deprecated, but not disabled).

I think I can count on one finger (and you can guess which one) the 
times I've used `foreach_reverse`.

-Steve


More information about the Digitalmars-d mailing list