Re: [fpc-devel] pure function feedback

2024-07-02 Thread J. Gareth Moreton via fpc-devel
Fixed!  Thanks again Marģers. Kit On 01/07/2024 18:09, Marģers . wrote: > Fixed 2 and 3. Thank you. one more ... {\$ifdef FPU_HAS_PURE}pure;{\$ENDIF} FPU_HAS_PURE probably is typo and should be: FPC_HAS_PURE -- This email has been checked for viruses by Avast antivirus software. www.avas

Re: [fpc-devel] pure function feedback

2024-07-01 Thread J. Gareth Moreton via fpc-devel
Oh yes, that's a silly mistake!  Easy enough to fix hopefully. Kit On 01/07/2024 18:09, Marģers . wrote: > Fixed 2 and 3. Thank you. one more ... {\$ifdef FPU_HAS_PURE}pure;{\$ENDIF} FPU_HAS_PURE probably is typo and should be: FPC_HAS_PURE -- This email has been checked for viruses by A

Re: [fpc-devel] pure function feedback

2024-07-01 Thread Marģers . via fpc-devel
> Fixed 2 and 3. Thank you. one more ... {\$ifdef FPU_HAS_PURE}pure;{\$ENDIF} > FPU_HAS_PURE probably is typo and should be: FPC_HAS_PURE  ___ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc

Re: [fpc-devel] pure function feedback

2024-07-01 Thread Marco van de Voort via fpc-devel
Op 1-7-2024 om 10:33 schreef Mattias Gaertner via fpc-devel: 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? Hmm, yes. You could maybe interface to the JVM and compile java that way. But I don't eve

Re: [fpc-devel] pure function feedback

2024-07-01 Thread J. Gareth Moreton via fpc-devel
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

Re: [fpc-devel] pure function feedback

2024-07-01 Thread J. Gareth Moreton via fpc-devel
In the case of JVM, the JIT compiler is specific to Java, I think.  Normally JIT requires the source code to be compiled into an intermediate bytecode first (e.g. Java bytecode or the Common Intermediate Language (.NET)). Kit On 01/07/2024 09:33, Mattias Gaertner via fpc-devel wrote: On 7/

Re: [fpc-devel] pure function feedback

2024-07-01 Thread Mattias Gaertner via fpc-devel
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 proba

Re: [fpc-devel] pure function feedback

2024-07-01 Thread J. Gareth Moreton via fpc-devel
Aah, thanks Marco.  I still have some things to learn about FPC! Kit On 01/07/2024 08: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

Re: [fpc-devel] pure function feedback

2024-07-01 Thread Marco van de Voort via fpc-devel
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

Re: [fpc-devel] pure function feedback

2024-06-30 Thread J. Gareth Moreton via fpc-devel
The main concept of pure functions is that they have no side-effects (e.g. don't affect a global state or rely on I/O) and are analogous to a mathematical function.  The main things to draw from it are that for constant inputs, the output is deterministic and can be calculated at compile time (

Re: [fpc-devel] pure function feedback

2024-06-30 Thread 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

Re: [fpc-devel] pure function feedback

2024-06-29 Thread J. Gareth Moreton via fpc-devel
Fixed 2 and 3. - 2 was due to not handling block nodes properly when they didn't have any statements (data-flow analysis stripped the procedure completely clean since no result was set), hence an access violation occurred while accessing a node that was nil. - 3 was a two-fold problem: 1. T

Re: [fpc-devel] pure function feedback

2024-06-28 Thread J. Gareth Moreton via fpc-devel
Hi Marģers, Thanks for the feedback! Assigning the results of pure functions to constants has not yet been developed.  I had planned to add it once the bulk of pure functions (i.e. the current merge request) had been approved since it requires some additional work (specifically what happens i

[fpc-devel] pure function feedback

2024-06-28 Thread Marģers . via fpc-devel
1. pure function value to constants function foo(i:longword):longword; pure; begin   foo:=9; end; const bar = foo( 8 );  //-- not allowed.. but i expect this to work! jar : longword = foo( 7 ); //-- and this as well 2. this does not end grasefully function foo (i:longword):shortstring;