[Xotcl] [self class] inside [eval]
Uwe Zdun
uwe.zdun at wu-wien.ac.at
Mon Sep 6 16:06:16 CEST 2004
Hi again,
well the problem here is the same as before. "eval" passes the control
to the Tcl eval command implementation.
That is, all what is called inside an "eval" in an object's namespace
bypasses the XOTcl dispatcher.
So the callstack entries are not correct. also filters/mixins do not
work here.
You should always use the XOTcl invocation syntax "objName methodName
args", like:
$newOb eval {
$newOb doStuff
}
I would like to make it impossible to call doStuff directly here, as in
the example below, but this would
require changes to the Tcl core or has a performance impact; so we chose
to live with the problem that
procs can be called directly via the namespace
Uwe
Kristoffer Lawson wrote:
>
> 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/
> _______________________________________________
> Xotcl mailing list - Xotcl at alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
--
Uwe Zdun
Department of Information Systems, Vienna University of Economics
Phone: +43 1 313 36 4796, Fax: +43 1 313 36 746
zdun at acm.org, uwe.zdun at wu-wien.ac.at
More information about the Xotcl
mailing list