Difference between revisions of "Const"

From Mesham
Jump to navigationJump to search
m
m
Line 15: Line 15:
  
 
The code in the above example will produce an error. Whilst the first assignment (''a:=34'') is legal, on the subsequent line the programmer has modified the type of ''a'' to be that of ''a'' combined with the type ''const''. The second assignment is attempting the modify a now read only variable and will fail.
 
The code in the above example will produce an error. Whilst the first assignment (''a:=34'') is legal, on the subsequent line the programmer has modified the type of ''a'' to be that of ''a'' combined with the type ''const''. The second assignment is attempting the modify a now read only variable and will fail.
 +
 +
''Since: Version 0.41b''
  
 
[[Category:Type Library]]
 
[[Category:Type Library]]
 
[[Category:Compound Types]]
 
[[Category:Compound Types]]
 
[[Category:Attribute Types]]
 
[[Category:Attribute Types]]

Revision as of 18:18, 13 January 2013

Syntax

const[ ]

Semantics

Enforces the read only property of a variable.

Example

var a:Int;
a:=34;
a:(a :: const[]);
a:=33;

The code in the above example will produce an error. Whilst the first assignment (a:=34) is legal, on the subsequent line the programmer has modified the type of a to be that of a combined with the type const. The second assignment is attempting the modify a now read only variable and will fail.

Since: Version 0.41b