Contents
Syntax
The syntax for
scope() scope{option}(var)
@scope() @scope{option}(var)
Description
The
- takes zero parameters and returns the current scope; or
- takes a single variable parameter and either returns the scope the variable is defined at or with the
in option returns the set of scopes at which the variable can be accessed from
Options
The following options are available for
option | description |
---|---|
return set of scopes at which variable can be accessed from | |
option | description |
f++ example
Example of
function(example.fn) { :={scope+="teji."}(int, x=0) console(scope(x)) console(scope{in}(x)) } example.fn()
n++ example
Examples of
@function(example.fn) { @:={scope+="teji."}(int, x=0) @console(@scope(x)) @console(@scope{in}(x)) } @example.fn()
@:={private}(int, obj.pair.first, obj.pair.second) @funcdef{private}(obj.pair.set){} @funcdef(another.example.func) { @console("current scope: '@scope()'") } @console("root scope: '@scope()'") @console("scope of obj.pair.first: '@scope(obj.pair.first)'") @console("scope of obj.pair.set: '@scope(obj.pair.set)'") @another.example.func() @/* expected output: root scope: '' scope of obj.pair.first: 'obj.pair.' scope of obj.pair.set: 'obj.pair.' current scope: 'another.example.' */