Enforced immutability: Difference between revisions

Content added Content deleted
imported>Acediast
m (→‎{{header|COBOL}}: Indentation.)
Line 239: Line 239:
Constants in COBOL are not stored in memory, but are closer to C's macros, by associating a literal with a name.
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:
Prior to COBOL 2002, you could define figurative literals for characters only:
<syntaxhighlight lang="cobol">ENVIRONMENT DIVISION.
<syntaxhighlight lang="cobol"> ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
SPECIAL-NAMES.
SYMBOLIC CHARACTERS NUL IS 0, TAB IS 9.</syntaxhighlight>
SYMBOLIC CHARACTERS NUL IS 0, TAB IS 9.</syntaxhighlight>


A new syntax was introduced in COBOL 2002 which allowed defining constants for other types.
A new syntax was introduced in COBOL 2002 which allowed defining constants for other types.
<syntaxhighlight lang="cobol">01 Foo CONSTANT AS "Foo".</syntaxhighlight>
<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:
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>
<syntaxhighlight lang="cobol"> 78 Foo VALUE "Foo".</syntaxhighlight>
Another was the <code>CONSTANT SECTION</code>:
Another was the <code>CONSTANT SECTION</code>:
<syntaxhighlight lang="cobol">CONSTANT SECTION.
<syntaxhighlight lang="cobol"> CONSTANT SECTION.
01 Foo VALUE "Foo".</syntaxhighlight>
01 Foo VALUE "Foo".</syntaxhighlight>


=={{header|D}}==
=={{header|D}}==