[fpc-devel] Pure function Wiki page

Martin fpc at mfriebe.de
Sun Jul 8 20:00:17 CEST 2018


On 08/07/2018 16:50, J. Gareth Moreton wrote:
> Hi everyone,
>
> With some blessing from Florian on the concept, I've set up a Wiki 
> page discussing the design proposals for the support of pure 
> functions, as well as some explanation on what they actually are.
>
> wiki.freepascal.org/Pure_functions
>
> I hope it proves useful to explain what I'm doing. How do the 
> proposals look so far, Florian?

I seem to be missing a part of the feature (or did I misunderstand (part 
of)  the side?

It is all about the compiler evaluating pure functions at compile time, 
and placing the result as a constant in the code. (Or at least that's 
how I read it).
That's all fine.

But what about re-using results at runtime.

    b := sin(x);
If x is unknown this can not be computed at compile time.
But
   if sin(x) > y then b := sin(x);

Knowing that sin is pure AND knowing that x did not change, means only 
one call is needed.
Is that also planed?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180708/a32828b4/attachment.html>


More information about the fpc-devel mailing list