assert() vs. enforce(), invariant() vs. ... ?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Aug 31 10:00:10 PDT 2013


On 8/30/13 9:55 PM, Maxim Fomin wrote:
> On Friday, 30 August 2013 at 21:11:32 UTC, Andrei Alexandrescu wrote:
>>
>> * typedef: it was so ill defined, bringing it any closer to sanity
>> would've broken someone's code.
>
> I haven't heard about any specific troubles with typedef which are
> reason to depreciate the feature.

The problem is nobody could agree whether typedef was a supertype or a 
subtype of its original type. It was just a bizarre teratoma grown by 
happenstance.

> In addition to typedef some other
> features are also experiencing troubles (shared, ref, properties,
> invariants,..) yet they are not deprecated.

That's not an argument.

>> * delete: a festering dung of unsafety straight in the middle of the
>> language.
>
> It was useful to delete class objects at the time where programmer knew
> that he can delete safely to mitigate the problem of dangling references
> upon class finalization (by invoking dtor when objects are alive). Right
> now there is no way to do that. By the way, currently dmd accepts
> putting @safe attribute on class dtor definitions which access GC
> objects - this is a hole in @safety (accessing such elements is not a
> sufficient reason to be hole in safity, but not reseting pointers to
> null is).

That would be a bug.

>> If there's enough argument that the functionality of delete is
>> actually desirable we can always add a function for that.
>
> Probably yes.
>
>> * scope: cute and dangerous in equal proportions - great for a movie
>> character, terrible for language design.
>>
>>
>> Andrei
>
> I cannot remember any feature implemented in phobos that was better then
> built-in language construct, including scope. Hasn't C++ followed the
> same policy and at the end it was considered as mistake?

Not sure I understand.

> At least D has
> many built-in features comparing to C++ and this is advertized as an
> advantage.

I don't think that's how I see things.


Andrei


More information about the Digitalmars-d mailing list