Skip to content

Variables Down

Benedict Albrecht edited this page Jun 2, 2026 · 3 revisions

Variables: :down Scope

The :down scope makes a variable visible only for downstream (child) elements. It follows hierarchical order: new overwrites old.

Syntax

<< name:down >>

Example

class C1 ( ) {
  let hhh ;

  function F1 ( hhh ) {
    let bbb = hhh;
  }

  let ccc = hhh;
}

With :down scope

<: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 parameter hhh (downstream of function)
  • let ccc = hhh → resolves to the outer let hhh (the parameter is not visible at the sibling level)

Compared to default (:following)

<: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.



In Practice

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

Clone this wiki locally