Files
mgmt/lang/interpret_test/TestAstFunc2/class-include-as-nested1.txtar
James Shubin 51cf1e2921 lang: ast: The res and edge names should not use exclusives
This removes the exclusive from the res names and edge names. We now
require that the names should be lists of strings, however they can
still be single strings if that can be determined statically.
Programmers should explicitly wrap their variables in a string by
interpolation to force this, or in square brackets to force a list. The
former is generally preferable because it generates a small function
graph since it doesn't need to build a list.
2024-04-18 00:07:53 -04:00

48 lines
1.2 KiB
Plaintext

-- main.mcl --
$top = "top-level"
class base($s) {
test ["middle " + $s,] {}
$middle = "inside base"
}
# syntactic sugar for the equivalent of defining a class `inner` inside of base.
class base:inner1($s) {
test ["inner1 " + $s,] {}
$last = "i am inner1 and i can see " + $middle
}
class base:inner2($s) {
test ["inner2 " + $s,] {}
$last = "i am inner2 and i can see " + $middle
}
# three deep!
class base:inner1:deep($s, $b) {
test ["deep is " + $s,] {}
$end = "i am deep and i can see " + $middle + " and last says " + $last
}
include base("world") as b0
include b0.inner1("hello") as b1 # inner comes out of `base`
include b0.inner2("hello") as b2 # inner comes out of `base`
include b1.deep("deep", true) as d # deep comes out of `inner1`
test "${top}" {}
test "${b0.middle}" {}
test "${b1.last}" {}
test "${b2.last}" {}
test "${d.end}" {}
-- OUTPUT --
Vertex: test[deep is deep]
Vertex: test[i am deep and i can see inside base and last says i am inner1 and i can see inside base]
Vertex: test[i am inner1 and i can see inside base]
Vertex: test[i am inner2 and i can see inside base]
Vertex: test[inner1 hello]
Vertex: test[inner2 hello]
Vertex: test[inside base]
Vertex: test[middle world]
Vertex: test[top-level]