[fpc-devel] XML node dump feature

J. Gareth Moreton gareth at moreton-family.com
Wed Jun 26 07:48:31 CEST 2019


Maybe I'm misreading this, but does that mean you're not a fan of the 
"pure" directive, Jonas?

My reasoning for including it as a directive and it not being automatic 
is that having the compiler determine if a function is pure or not is 
going to be an expensive operation and will also potentially cause 
problems akin to what I mentioned in another topic in that the nodes 
will be exposed in the PPU files.

To explain, the first pass of "pure" would probably be to just look for 
nodes that would be illegal, such as referencing pointers or calling 
other functions that aren't pure themselves - this will catch most 
cases, but not all of them.  The second pass is whenever a pure function 
is called, attempting to run through the nodes like it were an 
interpreted language to calculate the result, but it might then hit an 
infinite loop, or something that is not infinite but takes a 
disproportionately long time to compute (e.g. the Ackermann function, 
which would necessitate an upper limit on nodes parsed)... or hits a 
division by zero error, for example.

All in all, it feels to me that declaring a function as pure is best 
left in the hands of the user rather than the compiler.

Gareth aka. Kit

On 25/06/2019 20:27, Jonas Maebe wrote:
> On 25/06/2019 21:23, denisgolovan wrote:
>>> Complex types are built from primitive types. And if FPC can verify the
>>> "pure" attribute is valid, then LLVM can probably also come up with it.
>>> In fact, if FPC can verify it is valid, it can also come up with it
>>> itself and add it as an annotation in the LLVM bitcode.
>> AFAIU, "pure" attribute is planned to be user's responsibility and that's probably ok.
> That would definitely not be okay.
>
>
> Jonas
> _______________________________________________
> 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.
https://www.avast.com/antivirus



More information about the fpc-devel mailing list