Steven Schveighoffer schveiguy at
Tue Jan 25 05:20:26 PST 2011

On Mon, 24 Jan 2011 18:39:39 -0500, Simen kjaeraas  
<simen.kjaras at> wrote:

> Ellery Newcomer <ellery-newcomer at> wrote:
>> in the following:
>> void main(){
>>    char[] x;
>>    string s;
>>    string y;
>>    y = s ~ x;
>> }
>> tok.d(5): Error: cannot implicitly convert expression  
>> (cast(const(char)[])s ~ x) of type char[] to string
>> why should typeof(s ~ x) == char[] ?

I have since felt that the bug report I filed may be more trouble than  
it's worth.  It makes perfect sense for strings or other arrays of non  
references, but it doesn't make sense for more complex types (as can be  
seen by the later discussions on that report).

 From the original issue, s ~ x is concatenating two different types, what  
should the result type be?  Either choice is going to cause problems.  The  
only "correct" choice is a polysemous type that can implicitly cast into  
either type on the assumption that the data is unique.  This is pretty  
much what I wanted from the bug report, but I was very green back then,  
didn't know the right way to say it.

If the enhancement can be implemented, I think it would help, but it would  
be nice to solve this problem in the general sense (not just for arrays).   
There was a suggestion earlier that a strong-pure function could return an  
implicitly castable type, but concatenating a mutable and immutable string  
would not be such a function.  We would need some other way to mark a  


More information about the Digitalmars-d-learn mailing list