Pooh program example 08-object-prototype-finalizer.p

Test 08-object-prototype-finalizer.p

Source of programm

# test where object has a finalizer - it is called when object is freed.


a := { 'field' : 42, 
       'finalizer' : sub ()
                        println( ~msg 'finalizer is called' )
                     end
     }  



# assigning a different value to a; the previous value is now freed and finalizer is called.
a = {}


Standard output for 08-object-prototype-finalizer.p

finalizer is called

Trace output for 08-object-prototype-finalizer.p

004|a := { 'field' : 42 , 'finalizer' : sub () }
005|sub ()
006| println( ~msg 'finalizer is called' )...
005|end
013|a = {  }