-
Notifications
You must be signed in to change notification settings - Fork 0
Variables Down
The :down scope makes a variable visible only for downstream (child) elements. It follows hierarchical order: new overwrites old.
<< name:down >>
class C1 ( ) {
let hhh ;
function F1 ( hhh ) {
let bbb = hhh;
}
let ccc = hhh;
}<:function:>
function <<title>> ( <<NAME:down>> ) { <---> }
<:>
<:let:> let <<NAME>> <| = <<'name'>> <||> |> ; <:>
The function parameter hhh (declared with :down) is only visible within the function body:
-
let bbb = hhh→ resolves to the parameterhhh(downstream of function) -
let ccc = hhh→ resolves to the outerlet hhh(the parameter is not visible at the sibling level)
<:function:>
function <<title>> ( <<NAME>> ) { <---> }
<:>
<:let:> let <<NAME>> <| = <<'name'>> <||> |> ; <:>
With default scope, the parameter would also be visible to younger siblings, causing let ccc = hhh to resolve to the parameter instead of the outer variable.
The Basics grammar uses :down for class and function parameters:
class <<NAME:up>> ( <? <| , <||> <<NAME:down>> |> ?> ) { <-function, class, refference, variable-> }
In testFile.txt, class C1 (a , b , c ) captures parameters a, b, c with :down scope. These are visible inside the class body but not outside it.
In bridgeTest2.txt, function F4 ( eee, aaa, bbb ) captures eee with :down. Inside F4, let yyy = eee resolves to the parameter eee, not to variable eee in the parent class - the parameter shadows the outer variable.
See Repo Analysis - Variable Resolution for more shadowing examples.
See also:
:following·:up·:siblings·:global·:hook
- Getting Started
- Sign-Up
- Home Screen
- Creating Your First Template
- Template Editor
- Application Navigation
- Syntax Overview
- Workflow: End-to-End
- Workflow: Test with simpleDemo
- Workflow: Build Template from angularTemp
- Demo Repositories
- Template
- Workbench
- GitHub Integration
- GitHub App Installation
- GitHub Repository Setup
- GitHub Re-linking
- Settings
- Overview
- Declarations
- Types
- Scoping