No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] xotcl crash
From: Gustaf Neumann <neumann_at_wu.ac.at>
Date: Fri, 24 Jul 2009 10:21:04 +0200
# - if I create a method forwarding f1:
#
# obj forward f1 list {%_at_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 {%_at_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 {%_at_end 13} %self %1
>
> ? { obj f2 1 2 3 }
There is a bug in the current xotcl versions when both
%_at_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
Date: Fri, 24 Jul 2009 10:21:04 +0200
# - if I create a method forwarding f1:
#
# obj forward f1 list {%_at_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 {%_at_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 {%_at_end 13} %self %1
>
> ? { obj f2 1 2 3 }
There is a bug in the current xotcl versions when both
%_at_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