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

2008-09-18 Thread Graeme Geldenhuys
Hi, I was following a discussion in the delphi.non-technical newsgroup. They raised an issue about distinct types. I tried the following example under FPC and unexpectedly, FPC doesn't raise any errors! If you declare a distinct type as follows: type TMyInteger = type Integer; The type

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

2008-09-18 Thread Michael Van Canneyt
On Thu, 18 Sep 2008, Graeme Geldenhuys wrote: Hi, I was following a discussion in the delphi.non-technical newsgroup. They raised an issue about distinct types. I tried the following example under FPC and unexpectedly, FPC doesn't raise any errors! If you declare a distinct type as

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

2008-09-18 Thread Graeme Geldenhuys
On Thu, Sep 18, 2008 at 9:42 AM, Michael Van Canneyt [EMAIL PROTECTED] wrote: The type TMyInteger Integer so you are not supposed to be allowed to assign one to the other. Yet you can. See the following program. But obviously delphi also allows it ? It compiles everything, just not as a var

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

2008-09-18 Thread Michael Van Canneyt
On Thu, 18 Sep 2008, Graeme Geldenhuys wrote: On Thu, Sep 18, 2008 at 9:42 AM, Michael Van Canneyt [EMAIL PROTECTED] wrote: The type TMyInteger Integer so you are not supposed to be allowed to assign one to the other. Yet you can. See the following program. But obviously delphi

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

2008-09-18 Thread Marco van de Voort
In our previous episode, Michael Van Canneyt said: And it is also very annoying because Type MyString = type string; Const AString = 'something'; Var M : MyString; begin M:=AString; end. Will no longer compile if you are too strict. They should at least remain

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

2008-09-18 Thread Michael Van Canneyt
On Thu, 18 Sep 2008, Florian Klaempfl wrote: Michael Van Canneyt schrieb: On Thu, 18 Sep 2008, Graeme Geldenhuys wrote: Hi, I was following a discussion in the delphi.non-technical newsgroup. They raised an issue about distinct types. I tried the following example under

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

2008-09-18 Thread Florian Klaempfl
Michael Van Canneyt schrieb: On Thu, 18 Sep 2008, Graeme Geldenhuys wrote: Hi, I was following a discussion in the delphi.non-technical newsgroup. They raised an issue about distinct types. I tried the following example under FPC and unexpectedly, FPC doesn't raise any errors! If you

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

2008-09-18 Thread Yury Sidorov
From: Florian Klaempfl [EMAIL PROTECTED] Michael Van Canneyt schrieb: On Thu, 18 Sep 2008, Graeme Geldenhuys wrote: Hi, I was following a discussion in the delphi.non-technical newsgroup. They raised an issue about distinct types. I tried the following example under FPC and unexpectedly,

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

2008-09-18 Thread Graeme Geldenhuys
On Thu, Sep 18, 2008 at 10:11 AM, Michael Van Canneyt [EMAIL PROTECTED] wrote: And it is also very annoying because Type MyString = type string; Const AString = 'something'; Var M : MyString; begin M:=AString; end. Will no longer compile if you are too strict. They should at

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

2008-09-18 Thread Florian Klaempfl
Graeme Geldenhuys schrieb: On Thu, Sep 18, 2008 at 10:11 AM, Michael Van Canneyt [EMAIL PROTECTED] wrote: And it is also very annoying because Type MyString = type string; Const AString = 'something'; Var M : MyString; begin M:=AString; end. Will no longer compile if you are too

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

2008-09-18 Thread Florian Klaempfl
Yury Sidorov schrieb: From: Florian Klaempfl [EMAIL PROTECTED] Michael Van Canneyt schrieb: On Thu, 18 Sep 2008, Graeme Geldenhuys wrote: Hi, I was following a discussion in the delphi.non-technical newsgroup. They raised an issue about distinct types. I tried the following example under

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

2008-09-18 Thread Ivo Steinmann
Graeme Geldenhuys schrieb: Hi, I was following a discussion in the delphi.non-technical newsgroup. They raised an issue about distinct types. I tried the following example under FPC and unexpectedly, FPC doesn't raise any errors! If you declare a distinct type as follows: type TMyInteger

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

2008-09-18 Thread Graeme Geldenhuys
On Thu, Sep 18, 2008 at 11:34 AM, Florian Klaempfl [EMAIL PROTECTED] wrote: That's the whole point - it shouldn't be assignment compatible. You are creating a new MyString type, irrespective of what base-type it was based on. Only MyString types should be assigned to MyString types,

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

2008-09-18 Thread Florian Klaempfl
Graeme Geldenhuys schrieb: eg: #2 type MyType = type Double; MyOtherType = type Double; Otherwise, what's the different between a alias type (eg #1) and a distinct type (eg #2)?? As I said: overloading. It means: compatible but not equal. If you want distinct: use as said, classes,

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

2008-09-18 Thread Yury Sidorov
From: Florian Klaempfl [EMAIL PROTECTED] Yury Sidorov schrieb: From: Florian Klaempfl [EMAIL PROTECTED] Michael Van Canneyt schrieb: On Thu, 18 Sep 2008, Graeme Geldenhuys wrote: Hi, I was following a discussion in the delphi.non-technical newsgroup. They raised an issue about distinct

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

2008-09-18 Thread Florian Klaempfl
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? //-- type

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

2008-09-18 Thread Yury Sidorov
From: Florian Klaempfl [EMAIL PROTECTED] To: FPC developers' list fpc-devel@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

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

2008-09-18 Thread Florian Klaempfl
Yury Sidorov schrieb: From: Florian Klaempfl [EMAIL PROTECTED] To: FPC developers' list fpc-devel@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

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

2008-09-18 Thread Graeme Geldenhuys
On Thu, Sep 18, 2008 at 3:40 PM, Florian Klaempfl [EMAIL PROTECTED] wrote: 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. And which type is a generic

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

2008-09-18 Thread Yury Sidorov
From: Florian Klaempfl [EMAIL PROTECTED] Yury Sidorov schrieb: From: Florian Klaempfl [EMAIL PROTECTED] To: FPC developers' list fpc-devel@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

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

2008-09-18 Thread Martin Friebe
Florian Klaempfl wrote: Yury Sidorov schrieb: 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

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

2008-09-18 Thread Florian Klaempfl
Graeme Geldenhuys schrieb: On Thu, Sep 18, 2008 at 3:40 PM, Florian Klaempfl [EMAIL PROTECTED] wrote: 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. And

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

2008-09-18 Thread Florian Klaempfl
Yury Sidorov schrieb: From: Florian Klaempfl [EMAIL PROTECTED] Yury Sidorov schrieb: From: Florian Klaempfl [EMAIL PROTECTED] To: FPC developers' list fpc-devel@lists.freepascal.org Sent: Thursday, September 18, 2008 4:14 PM Subject: Re: [fpc-devel] Bug in FPC and declaring distinct types

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

2008-09-18 Thread Graeme Geldenhuys
On Thu, Sep 18, 2008 at 3:50 PM, Yury Sidorov [EMAIL PROTECTED] wrote: It makes implementation of utf8string impossible using this approach... I agree. I created a distinct string type (TfpgString) in fpGUI. That way I could ensure TfpgString is a UTF-8 string and String is a AnsiString

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

2008-09-18 Thread Yury Sidorov
] 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

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

2008-09-18 Thread Graeme Geldenhuys
On Thu, Sep 18, 2008 at 3:55 PM, Florian Klaempfl [EMAIL PROTECTED] wrote: Without any further code, the type 'asdf' is not defined, $H means only ansistring might be prefered. So does that mean if you have {$H+} enabled, then in the example below, the p1(ansistring) version will be called?

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

2008-09-18 Thread Florian Klaempfl
Yury Sidorov schrieb: 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

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

2008-09-18 Thread Graeme Geldenhuys
On Thu, Sep 18, 2008 at 10:51 AM, Florian Klaempfl [EMAIL PROTECTED] wrote: This is not true. The main purpose is to be able to overload functions/operators: type TUTF8String = type ansistring; enables you to overload all procedure already defined for ansistrings with UTF8String