Re: Great compiler bug! - Comparing events.

From: Andrew Cruickshank (andrew_at_openkast.com)
Date: 10/12/03


Date: Sun, 12 Oct 2003 21:18:54 +0100

Martin Harvey (Demon Account) wrote:
> On Sun, 12 Oct 2003 19:28:48 +0200, Marjan Venema
> <info@bjmsoftware.OhNoNotThis.com> wrote:
>
>
>>>Unfortunately, the line "if @Event1 = @Event2 then" doesn't compare
>>>the entire event, it only compares the code pointers. Oops!
>>
>>Sunday night may have dampened my brain's efficiency, but why do you
>>expect Delphi to compare entire events when you specifically request
>>address pointers with the @?
>>
>
>
> Because function and method pointers are the one situation where @
> does *NOT* mean take the address of".
>

The OPLG also only says that "@" operator gets the address
of the function or procedure.

You can read it both ways by implication:

   (a) that it will return the instance + method pointer value (64 bits)

or

   (b) that it will return the method pointer only (32 bits)

It looks like the compiler goes with (b). Arguably not a bug. However
it's a nasty little language hack IM(NV)HO.

--------------
Andrew.



Relevant Pages

  • Re: Great compiler bug! - Comparing events.
    ... >>expect Delphi to compare entire events when you specifically request ... In the case of *method pointers* this actually only compares the code ...
    (borland.public.delphi.language.objectpascal)
  • Re: .NET features youd like to see in Win32
    ... Reasons are, that one has full control over XML serialization and XML serialization is done using either a pre-built serializer using sgen, or an on-the-fly compiled one. ... Either way it is much faster than any RTTI based implementation in native Delphi. ... Also ADO.net and its interface based approach, combined with the extremely nice config system in .Net makes it a no-brainer to abstract your code from your DBMS. ... And none of them should have events made of dump method pointers. ...
    (borland.public.delphi.non-technical)
  • Re: Convert C-Builder program to Delphi?
    ... > many examples of Delphi 'method pointers'. ... from a powerful language to one less powerful, and you can't do that in ... in a dll under one or more classes or functions, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Convert C-Builder program to Delphi?
    ... > many examples of Delphi 'method pointers'. ... from a powerful language to one less powerful, and you can't do that in ... in a dll under one or more classes or functions, ...
    (comp.lang.cpp)
  • Re: Idea
    ... Not a bug considering how comparisons work in a low level in delphi. ... It's convenient, though, that the codegen for assigning ... internally it treats Int64s as method pointers. ... rather than typecast a machine type as a method pointer. ...
    (comp.lang.pascal.delphi.misc)