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

[Xotcl] [self class] inside [eval]

From: Kristoffer Lawson <setok_at_fishpool.com>
Date: Mon, 6 Sep 2004 16:05:22 +0300 (EEST)

Still looking for an official explanation for the operations of [eval]
(and other stuff I posted), but here's another one. The code follows:

package require XOTcl 1.3
namespace import xotcl::*

Class Foo -parameter doors

Foo instproc init {req} {
     puts $req
}


Object ob

set newOb [Foo new -childof ob hello -doors 4]
puts "Doors: [$newOb doors]"

$newOb proc doStuff {} {
     puts "class: [self class]"
     set newOb [[self class] new -childof [self] whatevah -doors 3]
     puts "Doors: [$newOb doors]"
}


$newOb doStuff

#$newOb eval {
# doStuff
#}

This version correctly states that the class for [self class] is an empty
string. However, if I comment out the "eval" version and use it instead,
[self class] gives me "::xotcl::Object".

                               / http://www.fishpool.com/~setok/