TDPL reaches Thermopylae level

Pelle Månsson pelle.mansson at gmail.com
Tue Oct 27 13:52:10 PDT 2009


Bill Baxter wrote:
> On Tue, Oct 27, 2009 at 1:06 PM, Pelle Månsson <pelle.mansson at gmail.com> wrote:
>> Bill Baxter wrote:
>>> On Tue, Oct 27, 2009 at 12:48 PM, Pelle Månsson <pelle.mansson at gmail.com>
>>> wrote:
>>>> Bill Baxter wrote:
>>>>> On Tue, Oct 27, 2009 at 6:56 AM, Michel Fortin
>>>>> <michel.fortin at michelf.com> wrote:
>>>>>> On 2009-10-27 09:07:06 -0400, Andrei Alexandrescu
>>>>>> <SeeWebsiteForEmail at erdani.org> said:
>>>>>>
>>>>>>> My current thought is to ascribe lhs ~ rhs the same type as lhs
>>>>>>> (thereby
>>>>>>> making ~ consistent with ~= by making lhs ~= rhs same as lhs = lhs ~
>>>>>>> rhs) in
>>>>>>> case lhs is a string type. If lhs is a character type, the result type
>>>>>>> is
>>>>>>> obviously the same as rhs.
>>>>>> Seems the most intuitive option to me. Also, it makes "a ~= b"
>>>>>> equivalent
>>>>>> to
>>>>>> "a = a ~ b" which is always nice.
>>>>> And that kind of suggests to me that even  a = b  should work.
>>>>> It has many of the same characteristics as ~=.  It's pretty
>>>>> unambiguous what you'd expect to happen if not an error.
>>>>>
>>>>>
>>>>> --bb
>>>> int a;
>>>> float b = 2.1;
>>>> a = b;
>>>> also unambiguous?
>>> I'm not sure what point you're trying to make, but wstring <-> string
>>> <-> dstring are all lossless conversions.  That isn't the case with
>>> int and float.
>>>
>>> --bb
>> They are?
>>
>> ...Then what is the point of wstring, dstring?
> 
> They are all just different representations of Unicode.
> 
> string, which is unicode in UTF-8, is good because it's the least
> wasteful for mostly ASCII text.  And has a nice ASCII backwards
> compatibility story.
> 
> dstring, which is unicode in UTF-32, is good because you have one
> element = one character.  So it's good for doing substring and other
> text manipulations.
> 
> wstring, which is UTF-16, is good because it lets you call Windows
> Unicode functions.
> 
> Here's Daniel Keep's nice explanation:
> http://docs.google.com/View?docid=dtqh79k_1rbxfmb
> 
> --bb
Thank you, that cleared things up for me :)



More information about the Digitalmars-d mailing list