[fpc-devel] Pure function Wiki page

J. Gareth Moreton gareth at moreton-family.com
Sun Jul 8 18:41:55 CEST 2018


 It's sort of the other way around.  The lack of the directive implies the
function is impure, and so the compiler won't bother with any kind of
purity check.  The presence of "pure" slows down the compiler, but
possibly producing much more efficient code.  Because pure functions will
be rare, it seems only right to mark the functions that definitely fulfil
the criteria (or so the programmer thinks), rather letting the compiler
attempt to find the pure functions itself, when upwards of 99% of them will
be impure.

 It also simplifies things for the programmer as far as constant assignment
is concerned, otherwise it might appear random and arbitrary in that some
functions can be assigned to constants, but not others, while throwing a
warning if a function is marked pure but actually isn't helps to inform the
programmer that they might have made a mistake.

 Gareth

 On Sun 08/07/18 18:33 , marcov at stack.nl (Marco van de Voort) sent:
 In our previous episode, Florian Kl?mpfl said: 
 > > 
 > > It doesn't explain why you chose for a modifier rather than
preprocessor 
 > > switch. 
 > 
 > Why a preprocessor switch for something which applies to a particular
function? 

 Maybe. But this kind of stuff will be rare, and is only an hint to speed
up 
 parsing. I think having a directive is a bit too much honor. 

 Maybe it is time for an attribute system? 
 _______________________________________________ 
 fpc-devel maillist - fpc-devel at lists.freepascal.org [1] 
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[2]">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel 

 

Links:
------
[1] mailto:fpc-devel at lists.freepascal.org
[2] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180708/67a5e074/attachment.html>


More information about the fpc-devel mailing list