issue-#115 Procedure pointers can't be compared

Post Reply
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

issue-#115 Procedure pointers can't be compared

Post by Ivan Denisov »

Procedure pointers can't be compared if their types was declared separately:

Code: Select all

MODULE A;

  TYPE
    Proc = PROCEDURE;

  PROCEDURE Test1 (): BOOLEAN;
    VAR
      P1, P2: PROCEDURE;
  BEGIN
    RETURN P1 = P2; (* ok *)
  END Test1;

  PROCEDURE Test2 (): BOOLEAN;
    VAR
      P1: PROCEDURE;
      P2: PROCEDURE;
  BEGIN
    RETURN P1 = P2; (* error *)
  END Test2;

  PROCEDURE Test3 (): BOOLEAN;
    VAR
      P1: Proc;
      P2: Proc;
  BEGIN
    RETURN P1 = P2; (* ok *)
  END Test3;

END A.
Reported by X512
http://community.blackboxframework.org/ ... p=638#p638
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#115 Procedure pointers can't be compared

Post by Zinn »

I don't see any error. It is perfectly alright.
You have the same behaivor with RECORDs when they declared directly and not via TYPE definition.
It is not a bug.
- Helmut
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#115 Procedure pointers can't be compared

Post by Josef Templ »

This is the intended behavior.
It gives you more control about what is compatible and what is not compatible.

A complex number, for example, could be represented using cartesian or polar coordinates.
Both have two REAL components but they are very different.
Structural equivalence would treat them as compatible, but name equivalence allows
you make them two incompatible types.

- Josef
User avatar
DGDanforth
Posts: 1061
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA
Contact:

Re: issue-#115 Procedure pointers can't be compared

Post by DGDanforth »

Josef Templ wrote:This is the intended behavior.
It gives you more control about what is compatible and what is not compatible.

A complex number, for example, could be represented using cartesian or polar coordinates.
Both have two REAL components but they are very different.
Structural equivalence would treat them as compatible, but name equivalence allows
you make them two incompatible types.

- Josef
That's a very nice example.
Post Reply