[lazarus] classesh.inc change required

Alexandre Grenier al.g at sympatico.ca
Wed Dec 22 13:29:32 EST 1999


> + From: Kevin Berry [mailto:kevinbe71 at yahoo.com]
> +
> + mmmm... just thought of something...
> + Because  "   MyVar: TMyFunc;" is present wouldn't
> + it still do type-checking anyway.
>
> Ok... I'm not into the compiler internals, but if I'm correct, if you have
> an untyped pointer, it is just a pointer and the compiler shouldn't
(can't)
> do typechecking anything else then if it is correct to asign a plain
> pointer.
>
> Marc

That's why I say not using @ is better.. that way it's more consistent. If
you assign a value to a var, the compiler will make sure that the types are
good.. and you can always do a typecast if you want to force it.

type
   TFunc1: function:Integer;
   TFunc2: function:Boolean;
var
    VarFunc1 : TFunc1
    VarFunc2 : TFunc2
    Int:Integer;

function Func1:Interger;
function Func2:Boolean;

VarFunc1:= Func1;
VarFunc2:= Func2;

Int:= VarFunc1;

// ^- that makes perfect sence, right?

Int:= VarFunc2;

// ^- that's not good, right?

VarFunc1:= @Func2;
Int:= VarFunc1;

// ^- then that's no good either....


Or I migh tjust be missing the point.







More information about the Lazarus mailing list