Hi Folks!
Seemingly the following code snippet cannot be compiled with the current GPC version:
Unit Foo;
Interface
Function Bar: integer;
Implementation
Function Bar = result: integer; begin (* Bar *) result:= 2; end (* Bar *);
end.
This results in a 'Header does not match previous definition' for function Bar.
Yours,
Markus
Markus Gerwinski wrote:
Seemingly the following code snippet cannot be compiled with the current GPC version:
Unit Foo;
Interface
Function Bar: integer;
Implementation
Function Bar = result: integer; begin (* Bar *) result:= 2; end (* Bar *);
end.
This results in a 'Header does not match previous definition' for function Bar.
Yes, according to the standard (*), the result variable must be present in the original declaration as well. GPC didn't check this before, but does now.
(*) This is only stated in the Object-Oriented Extensions, 6.7 (d):
: [...] and if one function definition contains a result variable : specification, then the other also has a result variable : specification of the same spelling.
It is a suggested change for an Extended Pascal revision (cf. 6.13). Whereas EP itself doesn't allow repetition of the function-heading at all, so you'd have to write (apart from using a module vs. a unit):
Unit Foo;
Interface
Function Bar = result: integer;
Implementation
Function Bar; begin (* Bar *) result:= 2; end (* Bar *);
end.
Frank