Task

Demonstrate a language's methods of:

   variable declaration
   initialization
   assignment
   datatypes
   scope 
   referencing,     and 
   other variable related facilities


//A constant declaration
let pi = 3.14
 
private {
    //private constant, not visible outside of a module
    let privateConst = 3.3
}
 
//Variable declaration
var x = 42
 
//Assignment
x = 42.42
 
//Dyalect is a dynamic language, so types are attached
//to values, not to the names
var foo = (x: 2, y: 4) //foo is of type Tuple
var bar = "Hello!" //bar is of type String
 
//Global variable
var g = 1.1
 
{
    //local variable (not visible outside of { } brackets)
    var loc = 2.2
}
 
func fun() {
    //Local variables, not visible outside of function
    var x = 1
    var y = 2
}
 
func parent() {
    //A local variable inside a parent function
    var x = 1
    func child() {
        //A local variable inside a nested function
        //It shadows a parent's variable
        var x = 2
 
        //But this is how we can reference a variable from 
        //a parent function
        base.x
    }
}