Re: [fpc-devel] Operator overloading question: Impossible to overload assignment for equal types. Why?

2024-04-26 Thread Bart via fpc-devel
On Thu, Apr 25, 2024 at 2:17 PM Sven Barth via fpc-devel wrote: >> I'll write a simple example in the wiki (there's a ToDo for that >> currently). > Please do.  Done. It's a bit more elaborate than just a few lines though. -- Bart ___ fpc-devel

Re: [fpc-devel] Operator overloading question: Impossible to overload assignment for equal types. Why?

2024-04-25 Thread Bart via fpc-devel
On Thu, Apr 25, 2024 at 2:17 PM Sven Barth via fpc-devel wrote: > Management operators are already part of 3.2.x ( > https://wiki.freepascal.org/FPC_New_Features_3.2.0#Management_operators_for_record_types > ). Or did I misunderstand your remark? 樂 I misread the wiki page (it mentions 3.1.1

Re: [fpc-devel] Operator overloading question: Impossible to overload assignment for equal types. Why?

2024-04-25 Thread Sven Barth via fpc-devel
Bart via fpc-devel schrieb am Do., 25. Apr. 2024, 11:48: > > > Then declare a Copy management operator in the record. Unlike an > assignment operator these *must* be part of the record, thus the same rules > are applied for the same type everywhere unlike for operator overloads. See > also

Re: [fpc-devel] Operator overloading question: Impossible to overload assignment for equal types. Why?

2024-04-25 Thread Bart via fpc-devel
On Thu, Apr 25, 2024 at 11:18 AM Sven Barth via fpc-devel wrote: > If there exists a built-in operator then overloading that operator is > forbidden to avoid confusion when what operator might be used (operators can > after all be declared *anywhere* and thus they might sometimes be used and

Re: [fpc-devel] Operator overloading question: Impossible to overload assignment for equal types. Why?

2024-04-25 Thread Sven Barth via fpc-devel
Bart via fpc-devel schrieb am Mi., 24. Apr. 2024, 11:59: > Overloading the := (assignment) operator for equal types is forbidden. > Out of curiosity I would like to know why that is? > If there exists a built-in operator then overloading that operator is forbidden to avoid confusion when what

Re: [fpc-devel] Operator overloading question: Impossible to overload assignment for equal types. Why?

2024-04-24 Thread Hairy Pixels via fpc-devel
> On Apr 24, 2024, at 4:59 PM, Bart via fpc-devel > wrote: > > In such instances it would really be helpfull if you could just > overload the assignment operator like: > operator := (Src: TRec): TRec; > begin > Result := AssignRec(Src); > end; I agree this seems reasonable but maybe the

[fpc-devel] Operator overloading question: Impossible to overload assignment for equal types. Why?

2024-04-24 Thread Bart via fpc-devel
Hi, Overloading the := (assignment) operator for equal types is forbidden. Out of curiosity I would like to know why that is? When you have e.g. a record definition containing a dynamic array, not being able to overload the assignment operator is just a PITA. OK, once you know why the