Demonstrate how to get the size of a variable.

See also: Host introspection

record rec0()
record rec4(a,b,c,d)
 
procedure main() # get size
 
every i := seq(1) do {
   a0 := &allocated
      x := case i of {
            1 : "ABCDEFGH"   
            2 : reverse(x)
            10 : &digits
            11 : x--x
            20 : []            
            21 : [1,2]
            22 : [1,2,3]
            30 : set()
            31 : set("X")
            32 : set("A","B")
            40 : table(1)
            50 : rec0()
            51 : rec4()
            60 : create seq(1)
            99 : break
            default : next
            }
   a1 := &allocated
   write("type=",type(x)," *x=",*x," bytes allocated=",a1-a0)
   }
end