Id have thought it would have complained at
jim:=x
as jim the parameter cant be set a value, it returnsone, but I guess theres tha possibility you're making use of the using the name of the function aspect as the return variable.
I guess then the other choice is
bill(jim);
where jim has no values sent to it.
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
I wouldnt expect it to, as what is jim called with? you expecting it to call it with 0?
I know the Jim can be, but at the same time think in most modern coding standards its frowned on as it is more confusing to read
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Would be best to ask them that.
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
It isn't a bug. Free Pascal is a little more strict about certain things than TP.
Your program should read:
program fred;
type funcparam=function(x:real):real;
function jim(x:real):real;
begin
jim:=x
end;
procedure bill(func:funcparam);
begin
writeln(func(3):5:2);
end;
begin
bill(@jim); { Notice that I am getting the address of the function 'jim' }
end.
This will compile properly in TP also.
Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
Hmm, you are right. My TP4 and TP5.5 both barf on both @x and addr(x).
This is one of those (relatively few) things that Borland did wrong (stunting the language). Alas. The only to make things work right with both FPC and TP is to use some conditional magic:
begin
{$ifdef FPC}
bill( @jim )
{$else}
bill( jim )
{$endif}
end.
Sorry about that. Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229