Demonstrate how to dynamically add variables to an object (a class instance) at runtime.

This is useful when the methods/variables of an instance are based on a data file that isn't available until runtime. Hal Fulton gives an example of creating an OO CSV parser at An Exercise in Metaprogramming with Ruby. This is referred to as "monkeypatching" by Pythonistas and some others.

 
Module checkit {
      class alfa {
            x=5
      }
      \\ a class is a global function which return a group
      Dim a(5)=alfa()
      Print a(3).x=5
      For a(3) {
            group anyname { y=10}
            \\ merge anyname to this (a(3))
            this=anyname
      }
      Print a(3).y=10
      Print Valid(a(2).y)=false
      \\ make a copy of a(3) to m
      m=a(3)
      m.y*=2
      Print m.y=20, a(3).y=10
      \\ make a pointer to a(3) in n
      n->a(3)
      Print n=>y=10
      n=>y+=20
      Print a(3).y=30
     \\ now n points to a(2) 
     n->a(2)   
     Print Valid(n=>y)=false  ' y not exist in a(2)
     Print n is a(2)  ' true
     \\ we don't have types for groups
     Print valid(@n as m)=false  ' n haven't all members of m
     Print valid(@m as n)=true  ' m have all members of n
}
checkit
 