automatic conversion to invariant (string?)

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Mar 20 09:15:27 PDT 2008


Yossarian wrote:
> Dne Thu, 20 Mar 2008 15:56:01 +0100 Janice Caron 
> <caron800 at googlemail.com> napsal/-a:
> 
>> On 20/03/2008, Yossarian <xtauer01 at stud.fit.vutbr.cz> wrote:
>>> but string is invariant(char)[]. and that's problem for me, because some
>>>  of the standard libraries aren't ready for this.
>>
>> Specifically, which ones?
> 
> 
> I can't, for example do this:
> throw new Error("This is an text of error");

I'm pretty sure you can, actually. You can't do it with a char[] 
parameter, but literals have invariant characters already and should 
work fine.

> I must do
> throw new Error(cast(string)"This is an text of error");

String literals implicitly convert to string, so the cast is completely 
unnecessary.



More information about the Digitalmars-d mailing list