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

[Xotcl] Question on [eval] method

From: Kristoffer Lawson <setok_at_fishpool.com>
Date: Thu, 2 Sep 2004 19:58:07 +0300 (EEST)

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/