[fpc-devel] pure function feedback
J. Gareth Moreton
gareth at moreton-family.com
Mon Jul 1 10:59:14 CEST 2024
On a related note, I do wonder where pure functions might help with
JIT. It depends on what Florian and the other administrators and
developers seek, but currently I aim for my pure function implementation
to fulfil both standard properties (1. same output for the same
input(s), and 2. no side-effects (usually interpreted as meaning reading
from or writing to anything outside of its scope (e.g. global variables))).
Currently, you can define a function as pure and, as long as you don't
have anything explicitly impure like a pointer deallocation, the
compiler won't know for sure if it is pure or not until you try to call
it with a constant parameter - then the compiler checks. This may cause
some issues if the function has a problem like an infinite loop or the
result not being set on some branches, and which won't be detected
unless you call the pure function with a constant input that triggers
the condition. I'm not sure what the best solution to this is.
Kit
On 01/07/2024 09:33, Mattias Gaertner via fpc-devel wrote:
>
>
> On 7/1/24 09:05, Marco van de Voort via fpc-devel wrote:
>>
>> Op 1-7-2024 om 02:34 schreef Hairy Pixels via fpc-devel:
>>> I had a question about pure functions. I'm seeing some newer
>>> languages have a JIT built-in so they can run any function at
>>> compile time. To get results at compile time you probably need to
>>> use a constant for the parameters but in theory it could read/write
>>> to global variables so it's not really "pure" but still makes it
>>> possible to run functions at compile time.
>>
>> FPC has JIT backends like JVM.
>
> But that is just the backend, FPC still works only at compile time, so
> no JIT at runtime possible. Is it?
>
> Mattias
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
--
This email has been checked for viruses by Avast antivirus software.
www.avast.com
More information about the fpc-devel
mailing list