[fpc-devel] Progress of pure function research

R0b0t1 r030t1 at gmail.com
Mon Jul 16 20:00:37 CEST 2018


On Mon, Jul 16, 2018 at 12:01 AM, J. Gareth Moreton
<gareth at moreton-family.com> wrote:
> Hi everyone,
>
> So I thought I'd do a little progress update on the pure function research.
>
> So far I'm mostly researching how the node builder works, specifically how inline
> functions are handled, since that's a situation where a 'call' node is
> effectively replaced, and I intend to builda similar system to handle pure functions.
>
> Designing an emulator to step through the nodes is a little tricker if only in
> regards to where it should slot into the project.  It's a fun challenge, but
> probably one of the most technical problems I've undertaken to date.
>
> The full design is a little awkward because I want to cover every eventuality,
> which is hard to predict.  Fully self-contained functions with only a single
> output parameter (i.e. the result) are relatively straightforward as I don't have
> to handle any calls to other pure functions, and the 'call' node can be replaced
> with a node representing a literal of some kind once it's calculated, but it gets
> more complicated if other pure functions are called inside it, there are 'out'
> parameters or there are difficult situations like infinite loops or code paths
> that simply take too long to complete.  There's also testing required to see if
> the functions still work with partial compilation (i.e. where some PPU files
> aren't rebuilt).
>
> As stated in the Wiki page, my first test case is the Max function.  Since it
> works both as an inline and a pure function, I can easily change the directive to
> analyse the code flow in the compiler.
>

The discussion about the potential implementation left me a bit
confused. I think part of what might need to happen is a better type
system, in part to keep track of constant expressions.

Cheers,
     R0b0t1



More information about the fpc-devel mailing list