### Compound Variables

Compound variables are a direct cousin of namespaces. They are actually nested namespaces. The effect is to provide something like data structures found in other languages. For example, you can create a record just by assigning into a compound variable:

Code Result
@ ~.Acct => @;
1001 => Acct.Num;
"XYZ Co." =>Acct.Name.Now;
"Was ABC Co."=>Acct.Name.Was;
('-<1>-'\$)(\$V Acct \$ \$v);
('-<2>-'\$)(\$V Acct.Name \$ \$v);
('-<3>-'\$)(\$V Acct.Name.Now \$ \$v);
-<1>-
CV[S41R3C2:K]
Assoc[I43R1C1:P]:Num:Num[1]
Assoc[I73R1C1:P]:Name:CV[2]
-<2>-
CV[S70R3C2:K]
Assoc[I72R1C1:P]:Now:String[7]
Assoc[I94R1C1:P]:Was:String[11]
-<3>-
String[S54R3C7:C]XYZ Co.
@ ~.rec => @;
100 => rec.units;
1.50 => rec.price;
rec.units * rec.price => rec.amount;
'Units:' rec.units \$;
'Price:' rec.price \$;
'Amount:' rec.amount \$;
Units:100
Price:1.5
Amount:150
@ ~(.a.t) => @;
10=>a.b.c.ten; 5=>a.b.c.five;
'-<Clumbsy>-' \$;
a.b.c.ten * a.b.c.five \$;
'-<Slick>-' \$;
a.b.c=>t;
t.ten * t.five \$;
-<Clumbsy>-
50
-<Slick>-
50
#ns => @; 10=>a.b.c; a.b=> x;
'-<1>-' \$;
{{20=>x.c;'Inside-No Arg: ' x.c\$;}};
'Outside-No Arg: ' x.c\$;
'-<2>-' \$;
x@[.x]{{20=>x.c;'Inside-w/Arg: ' x.c\$;}};
'Outside-w/Arg: ' x.c\$;
-<1>-
Inside-No Arg: 20
Outside-No Arg: 10
-<2>-
Inside-w/Arg: 20
Outside-w/Arg: 20
#ns => @;
'Beth' => acct.public.name;
'XYZ Co.' => acct.public.co;
{{
'Inside PW before: ' acct.private.password \$;
'Inside Co before: ' acct.public.co \$;
'Inside PW after: ' acct.private.password \$;
'Inside Co after: ' acct.public.co \$;
}};
'Outside Co: ' acct.public.co \$;
Inside PW before: sesami
Inside Co before: XYZ Co.
Inside PW after: xxx
Inside Co after:
Outside PW: sesami
Outside Co: XYZ Co.
#ns => @;
'Beth' => acct.public.name;
'XYZ Co.' => acct.public.co;
acct.public=>public;
public@[.r]{{
'Inside PW before: ' r.password \$;
'Inside Co before: ' r.co \$;
'New Co'=> r.co;
'Inside PW after: ' r.password \$;
'Inside Co after: ' r.co \$;
}};
'Outside private PW: ' acct.private.password \$;
'Outside Co: ' acct.public.co \$;