[article] Language Design Deal Breakers
Dmitry Olshansky
dmitry.olsh at gmail.com
Wed May 29 10:23:00 PDT 2013
29-May-2013 21:01, Timon Gehr пишет:
> On 05/29/2013 03:15 PM, Dmitry Olshansky wrote:
[snip]
>> 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);
> }
>
Implying that if I pass int it would observe that bar(int.init) -->
bar(0) works by range propagation? Then yes, yet another reason not to
use it in constraints.
> 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.
Well in case of @disable this() structs it would contain definite
garbage (as in deterministic) :)
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list