Difference between revisions of "Declaredtype"

From Mesham
Jump to navigationJump to search
(Created page with '== Syntax == declaredtype varname; == Semantics == Will return the declared type of the variable. == Example == var i:Int; i:i::const[]; i:declaredtype i; [[Category:…')
 
(Example)
Line 12: Line 12:
 
  i:i::const[];
 
  i:i::const[];
 
  i:declaredtype i;
 
  i:declaredtype i;
 +
 +
This code example will firstly type ''i'' to be an [[Int]]. On line 2, the type of ''i'' is combined with the type [[const]] (enforcing read only access to the variable's data.) On line 3, the programmer is reverting the variable back to its declared type (i.e. so one can write to the data.)
  
 
[[Category:Sequential]]
 
[[Category:Sequential]]
 
[[Category:Types]]
 
[[Category:Types]]

Revision as of 22:05, 10 January 2010

Syntax

declaredtype varname;

Semantics

Will return the declared type of the variable.

Example

var i:Int;
i:i::const[];
i:declaredtype i;

This code example will firstly type i to be an Int. On line 2, the type of i is combined with the type const (enforcing read only access to the variable's data.) On line 3, the programmer is reverting the variable back to its declared type (i.e. so one can write to the data.)