[fpc-devel] Pure function Wiki page
J. Gareth Moreton
gareth at moreton-family.com
Mon Jul 9 18:59:24 CEST 2018
The intention is to perform the analysis of pure functions at the pre-compilation
stage where all the Pascal code is transmuted into nodes, which are
platform-independent and also have the advantage of not requiring total
rebuilding of a project, since it is these nodes that are stored in PPU files.
It may turn out that that is more difficult in practice, but that's the current
theory.
Everything will be programmed in Pascal... no platform-specific assembly language
(and I think that is a global rule with the Free Pascal Compiler because of cross
compilation). I admit I'm not sure what will happen if you try to use
floating-point numbers that the platform simply does not support, in which case,
ANY program that uses them might run into problems. If floats are however
emulated by the Free Pascal Compiler in these cases, then the same will happen
when pre-calculating the functions.
Just for some extra fun - this is a video that shows the Ackermann Function being
run on a relatively modern computer, and hence the importance of being able to
catch functions that will take too long to compute (but which are still
nonetheless "decidable"). https://www.youtube.com/watch?v=i7sm9dzFtEI&t=9m30s -
I've done some calculations by hand, and shown that storing and recalling partial
results to the Ackermann Function does reduce the amount of recursion required
(e.g. when calculating A(3,2), it comes across 7 results from the function with
smaller arguments that it can reuse later that can significantly cut down the
processing requird), but there are still cases that are too ridiculous to work
out, not least because the answer will cause an overflow (e.g. the result of
A(4,2) has almost 20,000 decimal digits and, naïvely, takes longer than the age
of the Universe to compute).
Gareth aka. Kit
On Mon 09/07/18 18:36 , "Thorsten Engler" thorsten.engler at gmx.net sent:
> > -----Original Message-----
>
> > From: fpc-devel On Behalf Of
> > Max Nazhalov via fpc-devel
>
> > Sent: Tuesday, 10 July 2018 02:25
>
> >
>
> > Just one question: doesn't all this new stuff
> introduce another kind
> > of mess during cross-compiling?
>
> >
>
> > E.g. some complex nested const.expr.
> "sin(cos(0.12345))" evaluated by
> > the compiler on x64 (double precision) is not
> the same as if it would
> > be evaluated by the compiled program itself
> running on some x32
> > (float80), or some future float128 alikes..
>
>
>
> How would that be any different from floating point consts currently that
> are defined with an expression involving calculations?
>
>
> _______________________________________________
>
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
>
>
>
More information about the fpc-devel
mailing list