Page 1 of 1

issue-#115 Procedure pointers can't be compared

Posted: Mon Jun 27, 2016 6:15 am
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

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

Posted: Mon Jun 27, 2016 6:44 am
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

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

Posted: Mon Jun 27, 2016 12:08 pm
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

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

Posted: Tue Jun 28, 2016 5:20 am
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.