[Xotcl] Weird behaviour
Murr, Florian
florian.murr at siemens.com
Thu Jan 5 14:04:26 CET 2006
I extracted the code below from a very large XOTcl program that I am
developing right now.
The output of the last line 'puts "uuuuu guest_bathroom3
[guest_bathroom3 currTemp]"' puzzles me!
If I uncomment the line 'set temp [Celsius2Kelvin 20]' the output is
even weirder (an error message).
Any helpful comments?
Regards,
- Florian
My code:
package require XOTcl
namespace import xotcl::my xotcl::self xotcl::next xotcl::Class
xotcl::@
namespace eval tih {
Class Floor -parameter {
{cubicles {}}
}
Class Room -parameter {
{cubicles {}}
}
Room instparametercmd currTemp
# --- 'unknown'-mechanism.
Floor proc createRoom01 {floor aName args} {
#set temp [Celsius2Kelvin 20]
set room [eval {Room create $aName} $args]
$floor lappend cubicles $aName
$room set Floor $floor
}
Floor instproc rooms {{a {}}} { ;# getter/setter
my instvar cubicles
if {[llength $a]} {
set itp [self]_createRoom01
interp create $itp
interp alias $itp unknown {} ::tih::Floor createRoom01
[self]
set rval [$itp eval $a]
interp delete $itp
return
}
set rval [list]
foreach i $cubicles {
# xxx verbessern!
if {[$i istype Room]} { lappend rval $i }
}
set rval
}
proc Celsius2Kelvin {a} { expr {$a+273.15} }
Floor floor3 -rooms {
guest_room
guest_bathroom3 -currTemp [Celsius2Kelvin 30]
}
#puts "uuuuu guest_room [guest_room currTemp]"
puts "uuuuu guest_bathroom3 [guest_bathroom3 currTemp]"
}
More information about the Xotcl
mailing list