Debian Codegraph @

lang/interpret_test/TestAstFunc2/import-scope-classes5.txtar

raw
1 -- main.mcl --
2 $x = "i am x" # i am top-level
3
4 class c2() {
5 $y = "i am y and " + $x
6
7 #$x = $x # might be allowed, i don't _really_ care, but i prefer not
8
9 # We need to be able to re-define our new $x that shadows the parent $x,
10 # but it should be able to incorporate the parent (top-level) $x into
11 # the new value that this new $x here becomes.
12 # XXX: not supported for now: could not set scope: not a dag
13 # Sam suggested the RHS $x should have a special keyword to make it
14 # refer to the parent scope. I suggested when $x is also on the LHS,
15 # then this magic keyword should be implied. And only possible in the
16 # case for variables on the RHS that are the same var as on the LHS.
17 #$x = $x + " and this is shadowed" # this is important
18 }
19
20 include c2 as f1
21
22 test "${x}" {}
23 test "${f1.y}" {}
24
25 # the really tricky case
26 # XXX: not supported for now: could not set scope: not a dag
27 #test "${f1.x}" {}
28
29 -- OUTPUT --
30 Vertex: test[i am x]
31 Vertex: test[i am y and i am x]