Re: [fpc-pascal] Object questions
Am Di., 4. Dez. 2018, 08:00 hat Ryan Joseph geschrieben: > > > > On Dec 4, 2018, at 1:52 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > The type of "Self" inside a object is always the same no matter if it's > allocated on the stack or the heap. > > Then there’s now way to do a free method like I showed? > Correct. > > > > 2) Is there any TObject support in objects? I know there is a VMT table > for objects but I’m not sure if it’s structure is public in the RTL. > > > > class function TMyObject.ClassName:string; > > begin > > result := PVmt(self)^.vClassName^; > > end; > > > > Objects don't have TObject-like functionality. There is a VMT record, > but that is only available if there is at least one virtual method. > > I got a crash on that code but maybe it’s because of “self” or is the VMT > table for objects not “VMT” from the RTL? > The VMT for objects is currently only available locally inside the Objects unit (search for TVMT there). There is a bug report however to publish it... Though even then it is much less powerful than a class - there's a reason Borland reinvented the wheel there. Regards, Sven > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Can't determine which overloaded function to call
Hi *, this code compiles for target Win32 but does not compile for Win64/x86-64. Why? Is there workaround? (Error: Can't determine which overloaded function to call) Thank you -Laco. === code sample === TRec1 = record x,y: integer; function Offset(const Ax,Ay: integer): TRec1; overload; function Offset(const Ax,Ay: single): TRec1; overload; end; function TRec1.Offset(const Ax,Ay: integer): TRec1; begin end; function TRec1.Offset(const Ax,Ay: single): TRec1; begin end; var r1: TRec1; a,b: integer; begin r1 := r1.Offset(a-1,b-1); // HERE Error: end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Can't determine which overloaded function to call
El 04/12/18 a las 13:21, LacaK escribió: Hi *, this code compiles for target Win32 but does not compile for Win64/x86-64. Why? Is there workaround? (Error: Can't determine which overloaded function to call) Thank you For me, in win32 works fine try this r1.Offset(a-Integer(1),b-Integer(1)); or r1.Offset(Integer(a-1),Integer(b-1)); -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Can't determine which overloaded function to call
> >> Hi *, >> >> this code compiles for target Win32 but does not compile for >> Win64/x86-64. Why? Is there workaround? >> (Error: Can't determine which overloaded function to call) >> Thank you > For me, in win32 works fine Yes in Win32 works also for me. And this is my question why it does work in Win32 and does not work in Win64? > > try this > > r1.Offset(a-Integer(1),b-Integer(1)); does not helps > > or > > r1.Offset(Integer(a-1),Integer(b-1)); helps, but why is it not needed in Win32? Why for Win32 "integer"-"integer" is considered as "integer" so compiler can determine which overloaded function to call and for Win64 compiler compiler can NOT determine which overloaded function to call? It seems to me as inconsistent? L. === code sample === TRec1 = record x,y: integer; function Offset(const Ax,Ay: integer): TRec1; overload; function Offset(const Ax,Ay: single): TRec1; overload; end; function TRec1.Offset(const Ax,Ay: integer): TRec1; begin end; function TRec1.Offset(const Ax,Ay: single): TRec1; begin end; var r1: TRec1; a,b: integer; begin r1 := r1.Offset(a-1,b-1); // HERE Error: end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Can't determine which overloaded function to call
On 05/12/18 07:51, LacaK wrote: helps, but why is it not needed in Win32? Why for Win32 "integer"-"integer" is considered as "integer" so compiler can determine which overloaded function to call and for Win64 compiler compiler can NOT determine which overloaded function to call? It is because as documented at https://www.freepascal.org/docs-html/ref/refsu4.html (remarks under table 3.2), FPC evaluates integer expressions using the native integer type of the platform. On Win32 this is 32 bit, while on Win64 this is 64 bit. On the other hand, "integer" is always 32 bit in Delphi mode. This means that on Win32, there is an exact match for overload selection in your test program, while on Win64 there is not and the int64 -> integer and int64 -> single type conversions have the same priority. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal