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.
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@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
On Mon, 6 Sep 2004, Uwe Zdun wrote:
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.
OK, thanks. This is the information I was after. Ie. I should not assume that, though it might be kind of cool if there was a way to do what I was thinking.
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".
Then I actually gain very little compared to doing it inside namespaces. It would've helped for the methods to know their context and also for variables to be used (my first version did all this work manually). I can still get that with directly manipulating Tcl namespaces, I think, but it's just a tad more awkward than what I thought I'd get with XOTcl objects (because I also have to create structures and objects for my parser -- using namespaces instead of XOTcl obs).