AutoReleasePool sample



source ../../oo.tcl

@import core.*

#- myObject instances will say hello when initialised and goodby when released
@interface myObject : Object {
}
@implementation myObject {
  - init {} {
      $super init
      puts stdout "$self says hello !"
    }
  - dealloc {} {
      puts stdout "$self says goodbye !"
      $super dealloc
    }
}

#- creating pool object
pool = [AutoReleasePool new]

#- adding 10 myObject instances to current pool
for {i = 1} {$i < 10} {incr i} {
  [myObject new] autorelease
}

#- releasing pool object and all its content
$pool release