[fpc-devel] Bug in FPC and declaring distinct types

Yury Sidorov jura at cp-lab.com
Thu Sep 18 16:10:51 CEST 2008


From: "Florian Klaempfl" <florian at freepascal.org>
> Yury Sidorov schrieb:
>> From: "Florian Klaempfl" <florian at freepascal.org>
>>> Yury Sidorov schrieb:
>>>> From: "Florian Klaempfl" <florian at freepascal.org>
>>>> To: "FPC developers' list" <fpc-devel at lists.freepascal.org>
>>>> Sent: Thursday, September 18, 2008 4:14 PM
>>>> Subject: Re: [fpc-devel] Bug in FPC and declaring distinct types
>>>>
>>>>
>>>>> Yury Sidorov schrieb:
>>>>>>>> Yes. But it works only partially. For example the following 
>>>>>>>> code is not compilable:
>>>>>>>
>>>>>>> Well, I wouldn't know either what you expect :)
>>>>>>
>>>>>> I expect that compiler will choose DoTest with ansistring 
>>>>>> parameter in that case.
>>>>>
>>>>> What rule do you apply to say this?
>>>>
>>>> Compiler treats '1234' as ansistring constant. Therefore 
>>>> ansistring overload must be choosen here.
>>>
>>> No, '1234' is taken as generic string constant.
>>
>> Yes, I just tried to explain possible logic :)
>>
>> Also the following code is not possible currently:
>>
>> //------
>> operator := (const s: ansistring) r: TUTF8String;
>> begin
>> end;
>>
>> operator := (const s: TUTF8String) r: ansistring;
>> begin
>> end;
>> //------
>>
>> It makes implementation of utf8string impossible using this 
>> approach...
>>
>
> We discussed this once and concluded, that something like this hurts 
> more than it helps because an overloaded assignment operator allows 
> the compiler always to mess really around :)

Maybe.
But you stated that it is possible to create fully functional 
utf8string type from ansistring. :)
Unfortunately it is not true :(

Yury.



More information about the fpc-devel mailing list