[dmd-beta] dmd 2.064 beta take 2
Kenji Hara
k.hara.pg at gmail.com
Wed May 15 23:49:22 PDT 2013
2013/5/16 Don Clugston <dclugston at gmail.com>
> On 15 May 2013 23:19, Andrei Alexandrescu <andrei at erdani.com> wrote:
>>
>> I'm not assuming you're proposing this, but I'm clarifying just in case:
>> a member that takes per-instance memory YET always has the same value in
>> all objects would be positively useless. _That_ should at best be an error.
>>
>
> Great! This is exactly my argument. In that case we are actually in
> agreement. Thats the case I want to disallow.
>
Why it should be error? Yes, it would be finally redundant, but the
redundancy is necessary to keep meta-programming simple.
import std.traits;
struct MyData(T) if (isIntegral!T) {
T value = 10; // provides default value
alias value this;
this(T v) { value = v; }
}
With 2.062 and earlier, this simple MyData struct did not work when T is
non-mutable integer type. To support it, it had been required that checking
T is non-mutable and then remove constructor.
import std.traits;
struct MyData(T) if (isIntegral!T) {
T value = 10; // provides default value
alias value this;
static if (!is(T == const) && !is(T == immutable))
{ // necessary for 2.062 and earlier
this(T v) { value = v; }
}
}
This is definitely unnecessary complexity. Why you need this?
D should have ability for writing efficient code, but D should not enforce
writing efficient code to users.
Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20130516/1ac671d5/attachment-0001.html>
More information about the dmd-beta
mailing list