string concatenation
Nick Sabalausky
a at a.a
Thu Nov 19 05:48:21 PST 2009
"Ellery Newcomer" <ellery-newcomer at utulsa.edu> wrote in message
news:he2lm6$1h39$1 at digitalmars.com...
> Andrei Alexandrescu wrote:
>> Ellery Newcomer wrote:
>>> Andrei Alexandrescu wrote:
>>>> TDPL boasts the code:
>>>>
>>>> void main()
>>>> {
>>>> string a = "Hall\u00E5";
>>>> wstring b = ", ";
>>>> dstring c = "V\u00E4rld";
>>>> auto d = b ~ c; // d has type wstring, same as b
>>>> a ~= d ~ '!'; // concatenate string with character
>>>> writeln(a);
>>>> }
>>>>
>>>> We are having second thoughts about allowing b ~ c. It may be just a
>>>> bit
>>>> too clever. Also, figuring out the result type is not a slam dunk. The
>>>> pro arguments are that strings are already supported by the compiler in
>>>> iteration, literals, and concatenation of a char[] with a dchar.
>>>>
>>>> What say you?
>>>>
>>>>
>>>> Andrei
>>>
>>> What are the current ideas on result type and why don't they dunk?
>>
>> The result type would be the type of the left-hand side. This makes ~
>> consistent of sorts with ~=.
>>
>
> That seems intuitive enough. Its what I would have guessed.
>
>>> (personally, I like the idea of a syntax for converting from one unicode
>>> representation to another)
>>
>> I don't think that's an option at the moment.
>>
>>
>> Andrei
>
> I don't know what I ended up saying, but I meant
>
> a = ""c ~ somewstring;
>
> beats
>
> a = std.utf.toString(somewstring);
> //no I'm not going to check if that's the right function
>
> am I still missing something?
Isn't there "to!(char[])(whateverKindOfString)"?
More information about the Digitalmars-d
mailing list