Re: Great compiler bug! - Comparing events.

From: Martin Harvey (Demon Account) (martin_at_pergolesi.demon.co.uk)
Date: 10/12/03


Date: Sun, 12 Oct 2003 19:02:42 +0100

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".

Doing:

"if Event1 = Event 2 then" means: "Call both function pointers and
compare the result"

"if @Event1 = @Event 2 then" means: "Compare the value of both
function pointers"

and

"if @@Event1 = @@Event 2 then" means: "Compare the address of both
function pointers"

It's in the OP language guide.

MH.



Relevant Pages

  • Re: storage for temporaries
    ... >> Netocrat wrote: ... >> allegedly have no pointers to ojbects!). ... I suppose it is unclear how to compare ... pointers on a system that doesn't have a flat memory model. ...
    (comp.lang.c)
  • Re: far pointer
    ... >they will compare equal regardless of whether or not ... If two pointers *that you could create without invoking undefined ... behavior* point to the same location, they will compare equal ... regardless of whether or not the bit patterns are the same. ...
    (comp.lang.c)
  • Re: Pointer equality and dereferencing
    ... a representation representing two different values. ... If a pointer to an object and a pointer past an array compare equal, ... a different array object that happens to immediately follow the first ... the attempt to verify that the pointers happen to have the ...
    (comp.std.c)
  • Re: Requesting advice how to clean up C code for validating string represents integer
    ... The standard form is like this, ... 1108 The sizeof operator ... ... being able to compare unrelated pointers, ... So long as the pointers are of the same type, ...
    (comp.lang.c)
  • Re: STL algorithms & operator overloading
    ... > I'm trying to sort vector of pointers to classes using STL ... do is to write a suitable function to compare two pointers to object by ...
    (alt.comp.lang.learn.c-cpp)