Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

deadalnix deadalnix at gmail.com
Sat May 18 17:23:34 PDT 2013


On Sunday, 19 May 2013 at 00:14:26 UTC, Walter Bright wrote:
>
>     this() { assert(0); }
>
> makes for a runtime check, not a compile time one. Compile time 
> checks are more efficient in both programmer time and run time.
>
> Note that C++11 8.4.3 has @disable as well, in the form:
>
>    S() = delete;
>

D has @disable. If default constructor are allowed, default 
constructor can be disabled, as any other declared symbol.

> With NotNull, the runtime check only happens upon assignment 
> and initialization from a pointer type. Dereferencing, copying, 
> etc., of NotNull entails zero runtime overhead and no checks.

People go for the shortest path. You end up having nullable 
everywhere. Experience have been a countless amount of time in 
bazillion programming languages. But it is probably too late to 
fix this in D anyway.


More information about the Digitalmars-d mailing list