Difference between revisions of "Currenttype"
From Mesham
Jump to navigationJump to search (Created page with '== Syntax == currentype varname; == Semantics == Will return the current type of the variable. == Example == var i: Int; var q:currentype i; Will declare ''q'' to be an…') |
m (4 revisions imported) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
== Semantics == | == Semantics == | ||
− | Will return the current type of the variable. | + | Will return the current type of the variable.<br><br> |
+ | ''Note:'' If a variable is used within a type context then this is assumed to be shorthand for the current type of that variable<br> | ||
+ | ''Note:'' This is a static construct and hence only available during compilation. It must be statically deducible and not used in a manner that is dynamic. | ||
== Example == | == Example == | ||
− | var i: Int; | + | function void main() { |
− | + | var i: Int; | |
+ | var q:currentype i; | ||
+ | }; | ||
Will declare ''q'' to be an integer the same type as ''i''. | Will declare ''q'' to be an integer the same type as ''i''. | ||
+ | |||
+ | ''Since: Version 0.5'' | ||
[[Category:Sequential]] | [[Category:Sequential]] | ||
[[Category:Types]] | [[Category:Types]] |
Latest revision as of 15:44, 15 April 2019
Syntax
currentype varname;
Semantics
Will return the current type of the variable.
Note: If a variable is used within a type context then this is assumed to be shorthand for the current type of that variable
Note: This is a static construct and hence only available during compilation. It must be statically deducible and not used in a manner that is dynamic.
Example
function void main() { var i: Int; var q:currentype i; };
Will declare q to be an integer the same type as i.
Since: Version 0.5