September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
14
Task/Variables/Zkl/variables.zkl
Normal file
14
Task/Variables/Zkl/variables.zkl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
var v; // global to the class that encloses this file
|
||||
class C{ var v } // global to class C, each instance gets a new v
|
||||
class C{fcn f{var v=123;}} // v can only be seen by f, initialized when C is
|
||||
class C{fcn init{var [const] v=5;}} // init is part of the constructor,
|
||||
so vars are promoted yo class scope. This allows const vars to be created at
|
||||
construction time
|
||||
var v=123; v="hoho"; //not typed
|
||||
class C{var v} // C.v OK, but just v is not found
|
||||
class C{var[const]v=4} // C.v=3 illegal (compile or run time, depending)
|
||||
class C{var[mixin]v=4} // the compiler treats v as an int for type checking
|
||||
class C{var[proxy]v=f; fcn f{println("my name is ",self.fcn.name)} }
|
||||
v acts like a property to run f so C.v is the same as C.f()
|
||||
class C{reg r} // C.r is compile time error
|
||||
r:=5; // := syntax is same as "reg r=5", convenience
|
||||
Loading…
Add table
Add a link
Reference in a new issue