[fpc-devel] Typed constants

J. Gareth Moreton gareth at moreton-family.com
Sun Mar 17 23:59:21 CET 2019


 I've actually had this problem myself - sometimes it's quite critical as
well because you might want things like

 const
   Pi: Double = 3.14159265359;
   HalfPi: Double = Pi / 2;  TwoPi: Double = 2 * Pi;

 Will return the illegal expression error as well, even if Pi is fully
declared elsewhere, and the only fix was to expand the Pi identifier into
the number it represents.  This might be a problem with "pure" functions
down the line as well.
 Gareth aka. Kit

 On Sun 17/03/19 23:50 , "Ryan Joseph" ryan at thealchemistguild.com sent:
 I just realized that typed constants exist and may need to be supported as
constants for generics but I’ve never used them myself (not sure when
they were introduced). 

 First test gives an error so it makes me wonder if they’re buggy and
should be allowed for generics. Should they? 

 const 
 kInt: integer = 100; 

 var 
 i: integer = kInt; // ERROR: Illegal expression 

 They don’t work for generics right now either because they appear as a
load node and are not discernible from a variable. Not even sure how to
know if a load node is a typed const or what these things really are. 

 Regards, 
 Ryan Joseph 

 _______________________________________________ 
 fpc-devel maillist - fpc-devel at lists.freepascal.org 
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[1]">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel 

 

Links:
------
[1] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190317/f57b8d90/attachment.html>


More information about the fpc-devel mailing list