Blocks and Scopes

Scott Waldron Updated by Scott Waldron

Dino uses braces { and } as block delimiters. A block in Dino defines a new scope where symbols reside. The top scope (anything not within {}) is called the global scope. Symbol redefinition is considered an error in Dino syntax. A symbol from an enclosing (parent) scope will be visible in a child scope, however the reverse is not true.

var x = 0; // this is in the global scope

{
var y = 0; // this is in a child scope
x += 10; // setting x from the global scope
}

var z = 0;
if true {
var z = 0; // error, symbol redefinition of z
}

{
var a = 0;
}
{
var a = 1; // ok, we are in different scope
}

{
var b = 0;
}
b = 10; // error, unknown symbol b

How did we do?

Variables

Built-In Functions

Contact