View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] Weird behaviour

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Thu, 05 Jan 2006 15:13:24 +0100

i am somewhat confused be the code (why are you creating and deleting
interpreters?)
is the following code doing, what you are trying? (aggregates rooms on
floors with a simple syntax)

-gustaf
===================================================
package require XOTcl
namespace import -force ::xotcl::*

namespace eval tih {
  Class Floor \
      -instproc has cmds {eval $cmds}
 
  Class Room -superclass Class \
      -parameter {{count 0} currTemp} \
      -instproc new args {
    set name "[self callingobject]::[namespace tail [self]]-[my incr count]"
    eval [self] create $name $args
      }

  Room room -parameter {{currTemp 300}}
  Room guestRoom -superclass room
  Room bathRoom -superclass room
  Room guestBathRoom -superclass bathRoom

  proc Celsius2Kelvin {a} { expr {$a+273.15} }

  Floor floor3 -has {
    guestRoom new
    guestBathRoom new -currTemp [Celsius2Kelvin 30]
  }

  puts "rooms on floor 3: [floor3 info children]"
  foreach c [floor3 info children] {
    puts "temperature in room $c is [$c currTemp]"
  }
 
}
exit