[Xotcl] xotcl crash

Gustaf Neumann neumann at wu.ac.at
Fri Jul 24 10:21:04 CEST 2009


# - if  I create a method forwarding f1:
#
# obj forward f1 list {%@end 13} %self
#
# ? { obj f1 1 2 3 }  [list ::obj 1 2 3 13]
# Question:
#
# Why ::obj was inserted at the beginning but not at the end?

The definition of f1 is an example is from the XOTcl tutorial
and registers a forwarder method named "f1" for the
object "obj". When "obj f1 <someactualargs>" is invoked,
it constructs a new Tcl command starting with "list",
adds an argument with the value of "13" to
the end of the argument list and the fully qualified
name of the object as first argument. So, the invoked
command will be "list ::obj <someactualargs> 13".

Concerning your question:
Since the forwarder was defined to add "13" at the end of
the actual argument list, is does so. If you want a forwarder
adding the object name to the end, use:

   obj forward f1 list {%@end %self}

and a call "obj f1 1 2 3" will return a list "1 2 3 ::obj".

 

 > 2- This forwarding method causes xotcl to crash:
 >
 > obj forward f2 list {%@end 13}  %self  %1
 >
 > ? { obj f2 1 2 3 }

There is a bug in the current xotcl versions when both
%@end and %1 is used, which will be fixed in the next release.
The %1 means that the first argument from the provided
argument list (here "1") will be placed at the given
position. The argument is consumed and the remaining
arguments (here "2" and "3") are appended to the arguments
from the forward definition. So, effectively,
"f1" and "f2" will have the same output.

Thanks for reporting!
-gustaf neumann


More information about the Xotcl mailing list