Enforced immutability: Difference between revisions

m
imported>Acediast
m (→‎{{header|COBOL}}: Indentation.)
Line 239:
Constants in COBOL are not stored in memory, but are closer to C's macros, by associating a literal with a name.
Prior to COBOL 2002, you could define figurative literals for characters only:
<syntaxhighlight lang="cobol"> ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
SYMBOLIC CHARACTERS NUL IS 0, TAB IS 9.</syntaxhighlight>
 
A new syntax was introduced in COBOL 2002 which allowed defining constants for other types.
<syntaxhighlight lang="cobol"> 01 Foo CONSTANT AS "Foo".</syntaxhighlight>
 
Prior to COBOL 2002, there were non-standard extensions available that also implemented constants. One extension was the the 78 level-number:
<syntaxhighlight lang="cobol"> 78 Foo VALUE "Foo".</syntaxhighlight>
Another was the <code>CONSTANT SECTION</code>:
<syntaxhighlight lang="cobol"> CONSTANT SECTION.
01 Foo VALUE "Foo".</syntaxhighlight>
 
=={{header|D}}==
Anonymous user