TDPL reaches Thermopylae level

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Oct 26 13:05:27 PDT 2009


Bill Baxter wrote:
> On Mon, Oct 26, 2009 at 11:51 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> Bill Baxter wrote:
>>> On Mon, Oct 26, 2009 at 8:47 AM, Jeremie Pelletier <jeremiep at gmail.com>
>>> wrote:
>>>> Andrei Alexandrescu wrote:
>>>>> 303 pages and counting!
>>>>>
>>>>> Andrei
>>>> Soon the PI level, or at least 10 times PI!
>>>>
>>> A hundred even. ;-)
>> Coming along. I'm writing about strings and Unicode right now. I was
>> wondering what people think about allowing concatenation (with ~ and ~=) of
>> strings of different character widths. The support library could do all of
>> the transcoding.
>>
>> (I understand that concatenating an array of wchar or char with a dchar is
>> already in bugzilla.)
> 
> So a common way to convert wchar to char might then become ""~myWcharString?
> 
> That seems kind of odd.

Well, I guess. In particular, to me it's not clear what type we should 
assign to a concatenation between a string and a wstring. With ~=, it's 
much easier...

>  Just using something like
> to!(char[])(myWcharString) seems less goofy to me.

Problem is, an append + one transcoding requires two allocations. We 
could always define routines in std.string or std.utf:

append(s, ws); // s ~= ws

but really it's quite unambiguous what ~= should do. A nod from the 
language is a nice touch.


Andrei



More information about the Digitalmars-d mailing list