Re: [fpc-devel] Pure function development

2020-04-29 Thread J. Gareth Moreton
Hi Sven, Thanks for the response.  Yes, this is all inside the compiler. Basically I need a means to keep track of the internal state of a function as I step through the nodes (a process I call 'node emulation'), namely local variables, parameters (if they're not const, they're basically just

Re: [fpc-devel] Pure function development

2020-04-29 Thread Jonas Maebe
On 29/04/2020 13:41, J. Gareth Moreton wrote: > Thanks for the response.  Yes, this is all inside the compiler. > Basically I need a means to keep track of the internal state of a > function as I step through the nodes (a process I call 'node > emulation'), namely local variables, parameters (if th

Re: [fpc-devel] Pure function development

2020-04-29 Thread J. Gareth Moreton
Constant propagation is only really beneficial for inline functions, although there is some crossover with pure functions. I was more meaning a system of tracking and storing these constants, or rather how they manipulate variables throughout a pure function. I've also found some annoying limi

Re: [fpc-devel] Pure function development

2020-04-29 Thread Jonas Maebe
On 29/04/2020 22:08, J. Gareth Moreton wrote: > Constant propagation is only really beneficial for inline functions, That is incorrect. > although there is some crossover with pure functions. I was more meaning > a system of tracking and storing these constants, or rather how they > manipulate va

Re: [fpc-devel] Pure function development

2020-04-29 Thread J. Gareth Moreton
So are you officially rejecting pure functions and my future work on them in this form? Gareth aka. Kit On 29/04/2020 21:40, Jonas Maebe wrote: On 29/04/2020 22:08, J. Gareth Moreton wrote: Constant propagation is only really beneficial for inline functions, That is incorrect. although the

Re: [fpc-devel] Pure function development

2020-04-29 Thread Jonas Maebe
On 29/04/2020 22:43, J. Gareth Moreton wrote: > So are you officially rejecting pure functions and my future work on > them in this form? I'm just trying to say that there is already a (primitive) framework for propagating constant values through functions (in the optconstprop unit), and also an e

Re: [fpc-devel] Pure function development

2020-04-29 Thread Sven Barth via fpc-devel
Am 29.04.2020 um 22:51 schrieb Jonas Maebe: On 29/04/2020 22:43, J. Gareth Moreton wrote: So are you officially rejecting pure functions and my future work on them in this form? I'm just trying to say that there is already a (primitive) framework for propagating constant values through function

Re: [fpc-devel] Pure function development

2020-04-29 Thread J. Gareth Moreton
On 29/04/2020 22:15, Sven Barth via fpc-devel wrote: Assuming we want to have support for constant evaluation of functions (and I do admit that sometimes that is a really nice to have), I don't really see a way around marking such functions somehow, cause otherwise we'd have to store the node t

Re: [fpc-devel] Pure function development

2020-04-29 Thread Jonas Maebe
On 29/04/2020 23:15, Sven Barth via fpc-devel wrote: > Assuming we want to have support for constant evaluation of functions > (and I do admit that sometimes that is a really nice to have), I don't > really see a way around marking such functions somehow, cause otherwise > we'd have to store the no

Re: [fpc-devel] Pure function development

2020-04-29 Thread Jonas Maebe
On 29/04/2020 23:29, J. Gareth Moreton wrote: > Pure functions are a slightly tricky one because there is a lot of > overlap with inline functions and constant propagation, and yet there > are concepts that aren't covered by either, such as 'promotion' of pure > function calls outside of loops and

Re: [fpc-devel] Pure function development

2020-04-29 Thread J. Gareth Moreton
I'm glad we agree that one benefit of pure functions is loop-hoisting.  I call them pure functions because that's the technical name for them: https://en.wikipedia.org/wiki/Pure_function - they're analogous to a mathematical function.  'Read-only' sounds a little ambiguous to me and not immedia

Re: [fpc-devel] Pure function development

2020-04-29 Thread Sven Barth via fpc-devel
Am 29.04.2020 um 23:59 schrieb J. Gareth Moreton: I suppose node emulation would be equivalent to constant propagation.  I sense we might need to refactor things afterwards so the same code can be reused for both purposes.  My current design for the emulation would introduce a new virtual metho