The current status of D?

Steven Schveighoffer schveiguy at yahoo.com
Fri Dec 2 12:58:42 PST 2011


On Fri, 02 Dec 2011 15:51:32 -0500, Mehrdad <wfunction at hotmail.com> wrote:

> On 12/2/2011 10:41 AM, Steven Schveighoffer wrote:
>> You can work around by explicitly instantiating with const, or by doing:
>>
>> writeln(cast(const)this);
> I'm trying to avoid cast at all costs in D (even more than in C++),  
> since D's casts are more dangerous than C++ casts. :\
> Thanks for the suggestion though! :)

It's understandable.  In this case, you are doing something that should be  
able to be implicit, in order to force IFTI to interpret a certain way.

In all reality, writeln should const-ify all its args, but it can't  
because phobos isn't const correct yet.

Another workaround which avoids casts is this:

const tmp = this;
writeln(tmp);

-Steve


More information about the Digitalmars-d mailing list