Worst ideas/features in programming languages?

Timon Gehr timon.gehr at gmx.ch
Thu Nov 11 02:20:50 UTC 2021


On 09.11.21 18:13, Atila Neves wrote:
> On Tuesday, 9 November 2021 at 16:37:37 UTC, Timon Gehr wrote:
>> On 08.11.21 15:04, Atila Neves wrote:
>>> On Friday, 5 November 2021 at 21:22:12 UTC, victoroak wrote:
>>>> [...]
>>>
>>> Interesting. Adding an invariant causes compilation to fail:
>>>
>>> ```
>>> foo.d(27): Error: variable `foo.main.x` `void` initializers for 
>>> structs with invariants are not allowed in safe functions
>>> ```
>>>
>>>
>>
>> Well, that makes some sense, but a struct can have an invariant 
>> without actually having it spelled out explicitly in the source code. 
>> Furthermore, adding contracts actually makes code less safe in 
>> -release mode.
> 
> IMHO -release mode really shouldn't be used, but since contracts are 
> supposed to prevent bugs from occurring, hopefully testing "proved" that 
> "none" exist.
> 
> In this case specifically, even with -release one gets a compiler error, 
> which is enough of a reason to add one methinks.

"Add an empty invariant to your types for maximum type safety", "we have 
constructors, but your types have to cope with arbitrary bit patterns 
anyway" or "this thing is @safe but some compiler backends may treat it 
as UB anyway" are The Last Thing D Needs.


More information about the Digitalmars-d mailing list