[article] Language Design Deal Breakers

Timon Gehr timon.gehr at gmx.ch
Wed May 29 10:01:11 PDT 2013


On 05/29/2013 03:15 PM, Dmitry Olshansky wrote:
> 29-May-2013 16:18, Dicebot пишет:
>> On Wednesday, 29 May 2013 at 09:28:38 UTC, Walter Bright wrote:
>>> The whole point of a notnull is to disallow default initialization.
>>
>> Beg my pardon if that was already discussed by how does that interfere
>> with various T.init use cases in current code? Most important, won't
>> some existing template constraints wrongly fail for such types?
>
> IMHO lvalueOf!T and rvalueOf!T are the only things a template
> constraints should care about. Both can be emulated with dummy functions
> that never get linked anyway. I think Denis proposed those long ago as a
> pull and we should have had them by now.
>

Agreed.

> In fact most of Phobos they already use in place lambdas to get mock
> l-values of type T.
>
> This begs the question of usefulness of T.init and should ALL types have
> it.
>

T.init also has some other subtle issues:

void bar(short x){ }

void foo(T)(T arg) if(is(typeof(bar(T.init)))){
     bar(arg);
}

It is easy to instantiate foo such that the constraint passes and the 
function body does not compile.


> Since we have @disable this() I'd say T.init is no longer as useful and
> general at best it defines binary mask to blit over uninitialized
> variables. In essence it's T.uninitialized.
>

Well, 'uninitialized' may mean it could be random garbage.


More information about the Digitalmars-d mailing list