The current status of D?

Steven Schveighoffer schveiguy at yahoo.com
Fri Dec 2 04:26:39 PST 2011


On Fri, 02 Dec 2011 02:25:26 -0500, Mehrdad <wfunction at hotmail.com> wrote:

> On 12/1/2011 1:24 PM, Buk wrote:
>> Is D ready for prime time?
> Idk, the fact that I run across transitive-const-related situations like
> stackoverflow.com/questions/7948612/annoying-transitive-const-ness-issue-in-d  
> <http://stackoverflow.com/questions/7948612/annoying-transitive-const-ness-issue-in-d>
> makes it so I can't use D at all, since it's hard to go around these  
> issues sometimes.

What you are missing is one of the same things I need for dcollections --  
tail const for structs.

Essentially, the problem boils down to, I want to be able to have  
const(Slice!T) turn implicitly into Slice!const(T).  Slice!const(T) is  
more usable because only the data pointed at is const, the internal pieces  
of the slice are not.

But to solve your original problem, this seems to work on 2.056, but is  
weird:

import std.stdio;

struct S
{
     int x;
     inout this(inout int t)
     {
         this.x = t;
     }
}

void main()
{
     int i = 1;
     immutable int i2 = 1;
     const int i3 = 1;

     auto s = S(i);
     auto s2 = S(i2);
     auto s3 = S(i3);
     auto s4 = const(S)(1);
     writefln("s: %s, s2: %s, s3: %s, s4: %s", typeof(s).stringof,  
typeof(s2).stringof, typeof(s3).stringof, typeof(s4).stringof);
}

outputs:
s: S, s2: immutable(S), s3: const(S), s4: S

The s4 is the weird part, I clearly asked for a const(S), and it gave me  
an S due to the inout parameter being mutable.  I might file a bug on  
this, but to be honest, I never envisioned how inout would work on a  
ctor.  The s, s2, and s3 parts are pretty cool though :)

> As long as the language suffers from const issues, I think, it won't be  
> ready for prime time, since 'const' is supposed to be one of its highest  
> strengths, and at the same time it's part-broken.

inout has fixed many of these issues.  There is still work to be done, but  
I think we're in a much better place than we were before.

-Steve


More information about the Digitalmars-d mailing list