[fpc-pascal] Bug?

Michael Van Canneyt michael at freepascal.org
Sat Jun 12 09:31:17 CEST 2010



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.



More information about the fpc-pascal mailing list