[lazarus] classesh.inc change required

Marc Weustink Marc.Weustink at cuperus.nl
Wed Dec 22 05:02:21 EST 1999


+ From: Peter Vreman [mailto:pfv at cooldown.demon.nl]

+ Alexandre Grenier wrote:
+ > I don't find it confusing...
+ >
+ > You create a procedural type.. and then a Var of that
+ type.. and assign it a
+ > value of the same type. Just like you would do with
+ integers.. or strings..
+ > Var:= Value.. so logical.
+ But...
+
+ procedure(function);
+
+ is the result of the function passed or the function as procvar?
+
+
+ procedure(procedurevar);
+
+ is the result of the procvar function passed or the procvar itself?
+
+ And what if the result of the function is a procvar?

It is pretty clear if you take the following rule into account:

If a function/procedure matches the type of the var, the adress of this
function/procedure is passed. In all other cases the evaluation of
function/procedure(?).

So in your example MyProc(MyFunc) it depends on the declaration of MyProc
and MyFunc. If MyProc expects a MyFunc type then myfunc is passed as procvar
otherwise its evaluated.

The same for procedure(procvar).


Thinking of this brought me to a drawback on using the @ operator.
Depending on the $T (or $TYPEDADDRESS) flag the result of the @ operator is
typed or untyped. In most cases you use untyped pointers (?). This means
that the following is correct

type
  TMyFunc: function:Integer;

var
  MyVar: TMyFunc;

function MyFunc:Interger;
function MyOtherFunc: TSomething;
procedure MyProc;

MyVar := @MyFunc;
MyVar := @MyOtherFunc; (??)
MyVar := @MyProc;      (??)

Marc






More information about the Lazarus mailing list