[Xotcl] [self class] inside [eval]

Kristoffer Lawson setok at fishpool.com
Mon Sep 6 15:05:22 CEST 2004

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/

More information about the Xotcl mailing list