[fpc-devel] Little question about the

J. Gareth Moreton gareth at moreton-family.com
Sat Aug 11 02:56:46 CEST 2018


 Sorry for not quite understanding what you mean.  Are you meaning that if
I detect something like this in the main file...

 ****
 program SomeProg;

 function PureFunc(A: Integer): Integer; forward;

 procedure TestFunc;
 begin  { Call PureFunc }
 end;

 function PureFunc(A: Integer): Integer; pure;
 begin
   { etc. }
 end;
 ****

 ... an error should be thrown?  But if something like this appears:

 ****
 unit SomeUnit;

 interface

 function PureFunc(A: Integer): Integer;

 implementation

 procedure TestFunc;
 begin  { Call PureFunc }
 end;

 function PureFunc(A: Integer): Integer; pure;
 begin
   { etc. }
 end;
 ****

 ... all is well?  Is it only problematic if a function is defined as
"forward" and not "pure" on the same line?

 Gareth aka. Kit

 On Fri 10/08/18 19:51 , "Sven Barth" pascaldragon at googlemail.com sent:
 J. Gareth Moreton  schrieb am Fr., 10. Aug. 2018, 18:44:
  Thanks Sven,
 Sorry if I'm bringing up obvious points.  I've set "pure" to be
interface-only - it's a little tricky because if you now specify it in the
main source file, it says that it can't be used in the implementation
section, even though, really, the main file doesn't have such section. 
Still, that can be dealt with.
 You shouldn't declare it as interface only, but you should disallow the
situation that it is not set for the forward def in the interface, but for
the one in the implementation section. Other combinations are valid.  I
think the function to look for is add_proc_definition (can't check
currently). Also the defs should contain methods to check whether they had
been declared in the interface or implementation section so you can use
those. 
 Regards, Sven   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180811/b823f66d/attachment.html>


More information about the fpc-devel mailing list