[fpc-pascal] Re: Bug?

Roger Bailey rb at doc.ic.ac.uk
Tue Jun 15 01:24:42 CEST 2010


Sorry, I committed the cardinal sin of getting the subject line wrong. Corrected now :-)

On 14 Jun 2010, at 18:07, Michael Van Canneyt wrote:

> On Mon, 14 Jun 2010, Roger Bailey wrote:
> 
>> On 12 Jun 2010, at 11:00, Michael Van Canneyt wrote:
>> 
>>>>> TestFunction := ActualParameter ( ) ; { compiles and runs o.k. }
>> 
>>> [MVC:] The addition of () actually calls the function.
>>> 
>>>>> TestFunction := ActualParameter ;     { gives "incompatible type" error, but ... }
>>> 
>>> [MVC:] 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. }
>> 
>>> [MVC:] This is simply a regular function call.
>> 
>> Sorry, but this simply wrong. The LRG (page 95) does not require an "actual parameter list" for a syntactically correct function call.
> 
> [MVC:] What is simply wrong ? My explanation or the behaviour of the compiler ?

Sorry. I guess your explanation states what the compiler is doing, so in that sense your reply isn't "simply" wrong. However, the program fragment "TestFunction := ActualParameter" is a syntactically correct function call as as defined by the LRG, so the statement "Here you try to assign the ActualParameter (a function pointer) to the result (an integer)" is wrong. In fact I now notice you you give an almost identical example in the LRG (page 96)

> Type
> FuncType = Function: Integer;
> Var A : Integer;
> Function AddOne : Integer;
> begin
> A := A+1;
> AddOne := A;
> end;
> Var F : FuncType;
> N : Integer;
> begin
> A := 0;
> F := AddOne; { Assign AddOne to F, Don’t call AddOne}
> N := AddOne; { N := 1 !!}
> end.

It's clear from this that the meaning of "Addone" depends on the context, here the type of the variable on LHS of the assigment. On this basis I think that the error message I received is either a compiler bug, or FPC implements a slightly perverse dialect of Pascal (so the LRG is wrong).

Hope this helps,
Roger Bailey


More information about the fpc-pascal mailing list