Object sample



source ../../oo.tcl

@import core.*

#- creating new object
o = [Object new]

#- can it respond to desc message ?
if [$o respondsTo: desc] {
  puts stderr [$o desc]
}

#- playing with referrence count
puts stderr "refCount: [$o refCount]"

for {i = 0} {$i < 3} {incr i} {
  $o retain
  puts stderr "refCount: [$o refCount]"
}
for {i = 0} {$i < 3} {incr i} {
  $o release
  puts stderr "refCount: [$o refCount]"
}

#- releasing object
$o release