[Xotcl] Question on [eval] method

Uwe Zdun uwe.zdun at wu-wien.ac.at
Mon Sep 6 15:53:16 CEST 2004


Hi Kristoffer,

I'm not pretty sure, what you want to reach here. The "eval" method 
provided by XOTcl does nothing
else then a Tcl eval in the context of the object's namespace. This is 
not meant for evaluating
methods, though it accidently works for local methods (procs), because 
they are defined
in the same namespace. In the example below, I would define the " 
commands" such as 'format', 'short', 'object'
as objects. Then you can use Tcl's eval to send messages to these 
objects, and define the first argument
as method or use "unknown".

Uwe

Kristoffer Lawson wrote:

>
> It states that object-local variables are accessible as normal Tcl 
> variables inside the script, but what about methods? I noticed the 
> following:
>
> % package require XOTcl
> 1.1
> ::ob
> % ob proc pomous {} {puts pomous}
> % ob eval pomous
> pomous
> % xotcl::Class JOu
> ::JOu
> % JOu instproc uoah {} {puts jeah}
> % JOu ob
> ::ob
> % ob eval uoah
> invalid command name "uoah"
>
> Is that guaranteed to work at all? Is there any proper way to get what 
> I want to do?
>
> The reason I'm doing this is because I'm implementing a type of binary 
> reading command which looks something like this:
>
> buynary::scan $clusterDat {
>     option endian little
>
>     format {
>     object root {
>         short objNum
>         short $objNum objIDs
>     }
>
>     object * children {
>         short 3 cellID
>
>         short addObjNum
>         short $addObjNum addObjIDs
>
>         short rmObjNum
>         short $rmObjNum rmObjIDs
>     }
>     }
> }
>
> It uses XOTcl to build a representation of the binary data as objects. 
> I made a version which parses the format manually, but for performance 
> reasons I'd like Tcl to do that. Ie. to have, in a particular context, 
> commands such as 'format', 'short', 'object' etc. Then I could just 
> [eval] the whole nonsense and get all the performance benefits that 
> has to offer.
>
> One could always do this using namespaces, but that would be really 
> annoying as I've started off with XOTcl for this.
>
>                              / 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