[fpc-pascal] Typed Constants vs. Variables

Richard Ward roward at mac.com
Mon Apr 6 16:20:16 CEST 2009


Jonas wrote:

b) conversely, initialized variables are initialized every time their  
scope is activated (or whatever the proper term for that is: once in  
case they are declared in a program/unit scope, and every time a  
function/procedure is entered if they are declared locally in a routine)

---

Thanks for this explicit clarification.   This was the bit of  
information which was not getting through to me before.

Francisco,

In FPC, there are two types of constants:   ordinary and typed.

"Ordinary" constants are what you were thinking of while "typed"  
constants act a bit differently as Jonas and lele wrote.   My  
confusion was that typed constants and initialized variables seemed to  
me to behave exactly the same - that is, acted like variables - until  
I learned the subtle difference in (b) above.   Although I can  
appreciate why the term "typed constant" was selected for such a  
language feature, it was confusing to me since I tend to think of  
constants as being "constant" and one has to be careful in realizing  
the difference lest things don't work the way as one might expect.  -  
ROW



More information about the fpc-pascal mailing list