On Sat, 12 Jun 2010, Roger Bailey wrote:
Can someone explain this?
program WhatsGoingOnHere ;
type
FunctionType = function : INTEGER ;
function NamedFunction : INTEGER ;
begin
NamedFunction := 12345 ;
end ;
function TestFunction ( ActualParameter : FunctionType ) : INTEGER ;
begin
TestFunction := ActualParameter ( ) ; { compiles and runs o.k. }
The addition of () actually calls the function.
TestFunction := ActualParameter ; { gives "incompatible type" error, but
... }
Here you try to assign the ActualParameter (a function pointer) to the
result (an integer). This of course gives a type error.
TestFunction := NamedFunction ; { ... compiles and runs o.k. }
This is simply a regular function call.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal