[fpc-pascal] Typed Constants vs. Variables

Francisco Reyes lists at stringsutils.com
Mon Apr 6 03:58:07 CEST 2009

Richard Ward writes:

> Where/why would one use a typed constant vs. a variable.  i.e.

Any time you have a value you want to have in an accessible holder, but want 
to ensure you will not change it's value by mistake.  

> It seems to me the typed constant is superfluous and can potentially  
> lead to bugs.

On the contrary. They help saveguards against bugs.
Imagine a team of people working on different parts of a large system.
One team defines a constant; someone on another team sees a piece 
of code and thinkgs he working with a variable. He tries to change it and 
the compiler throws an error because it is a constant. That error just saved 
that system from a logical, possibly hard to find, error.

More information about the fpc-pascal mailing list