[fpc-devel] Typed constants question

J. Gareth Moreton gareth at moreton-family.com
Sat Jul 28 15:12:28 CEST 2018


 So I have a question about constants.

 While programming pure functions, I noticed that typed and untyped
constants are treated differently.  Something like "const Pi = 3.14159",
even if declared outside of the current function, is propagated directly in
expressions - the node construction shows it loading the actual value. 
However, when you have something like "Const Pi: Double = 3.14159", it
instead accesses the symbol like a non-local variable. Normally I would
treat accessing such a variable as making the function ineligible to be
pure (as it's not self-contained), but is it safe to make an exceptional
case for constants, or is there something I'm missing (e.g. writable
constants).

 For a more fundamental question... why are typed and untyped constants
treated differently?

 Gareth aka. Kit
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180728/c9e1a285/attachment.html>


More information about the fpc-devel mailing list