<HTML>
<div><style> BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }</style>Given I want to be conservative with pure functions so it's near-impossible to write something that breaks the compiler or cause unexpected behaviour in the compiled binary, I'll treat the accessing of such a constant as "impure" for reasons of safety. My work-in-progress already detects accessing a non-local variable, and this also covers typed constants, and will remove the 'pure' flag and throw a compiler warning in this case.<br>
</div><div><br>
</div><div>Because I'm the developer of this feature, I can't guarantee that I won't overlook something when it comes to writing unit tests. I'll probably be relying on you guys to push the compiler and the 'pure' feature to breaking point!<br>
</div><div><br>
</div><div>Gareth aka. Kit<br>
</div> <br>
<br>
<span style="font-weight: bold;">On Sat 28/07/18 16:01 , marcov@stack.nl (Marco van de Voort) sent:<br>
</span><blockquote style="BORDER-LEFT: #F5F5F5 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">In our previous episode, J. Gareth Moreton said:
<br>
<br>
<br>
<span style="color: rgb(102, 102, 102);">> For a more fundamental question... why are typed and untyped constants
</span><br>
<span style="color: rgb(102, 102, 102);">> treated differently?
</span><br>
<br>
Turbo Pascal allowed to write them, depending on a switch. $J.
<br>
Delphi adds {$writeableconst on} iirc.
<br>
<br>
But even when this is off, you can't be sure it is on in a different module,
<br>
so exported constants can never be folded in. (except of course as a global
<br>
optimizations)
<br>
<br>
I guess for a local (implementation) constant this could be checked?
<br>
<br>
<br>
</blockquote></HTML>