<HTML>
<div><style> BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }</style>What Florian said. Only particular functions can be pure, and even if they are marked as such, the compiler has to make sure they are fulfil a strict set of criteria that requires a degree of data flow analysis, and this can quickly take far too long to complete, especially if the function contains a loop of some kind.<br>
<br>
It is a slightly tricky design, because I want to make sure a programmer can't write something that will crash the compiler (which is why I mention the Ackermann Function as a test case).</div><div><br>
</div><div>Anything that dereferences a pointer or accesses a dynamic array (which, internally, is a pointer to something on the heap) cannot be pure, and this covers the vast majority of the functions, but depending on how the function is written, it may not be apparent until the compiler has analysed the majority of the compiled nodes.</div><div><br>
</div><div>Just note... though strictly speaking, only functions can be pure, I haven't explicitly forbidden procedures from being pure, because if they have <span style="font-weight: bold;">out</span> parameters, then as long as they fulfil all the other criteria, they can be considered a function with multiple return values. Note that the presence of a <span style="font-weight: bold;">var</span> parameter instantly makes a function impure on account that the argument is, by definition, not constant.<br>
</div><div><br>
</div><div>Gareth<br>
</div> <br>
<br>
<span style="font-weight: bold;">On Sun 08/07/18 17:59 , Florian Klämpfl florian@freepascal.org sent:<br>
</span><blockquote style="BORDER-LEFT: #F5F5F5 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">Am 08.07.2018 um 18:55 schrieb Marco van de Voort:
<br>
<span style="color: rgb(102, 102, 102);">> In our previous episode, J. Gareth Moreton said:
</span><br>
<span style="color: rgb(102, 102, 102);">>> wiki.freepascal.org/Pure_functions
</span><br>
<span style="color: rgb(102, 102, 102);">>> I hope it proves useful to explain what I'm doing. How do the proposals
</span><br>
<span style="color: rgb(102, 102, 102);">>> look so far, Florian?
</span><br>
<span style="color: rgb(102, 102, 102);">>
</span><br>
<span style="color: rgb(102, 102, 102);">> It doesn't explain why you chose for a modifier rather than preprocessor
</span><br>
<span style="color: rgb(102, 102, 102);">> switch.
</span><br>
<br>
Why a preprocessor switch for something which applies to a particular function?
<br>
_______________________________________________
<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<br>
<a target="_blank" href="<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>"><span style="color: red;">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</span></a>
<br>
<br>
<br>
</blockquote></HTML>