This is with XOTcl 1.3.6, but I couldn't find if 1.3.8 fixes it. The following code does not appear to work as expected:
package require XOTcl namespace import xotcl::*
Class A
A instproc init {test} { puts "init: $test" }
A instproc foo {text} { puts "foo: $text" }
A instproc bar {text} { puts "bar: $text" }
A new "on taas" -foo jou -bar blah A new -foo jou -bar blah "on taas"
The first will work, but the latter will not. The error is:
wrong # args: should be "bar text" ::xotcl::__#1 ::A->bar ::xotcl::__#1 ::xotcl::Object->configure ::A ::xotcl::Class->create ::A ::xotcl::Class->new invoked from within "A new -foo jou -bar blah "on taas"" (file "dashCreateTest.tcl" line 23)
Kristoffer,
the arguments to the constructor are preceding in the call the values passed to configure. All the arguments of the call not strting with a dash are taken as arguments for init. So in:
Class C C c1 ene mene moo -f 1 2 3 -g drausst bist du
the arguments "ene mene moo" are passed to init, "1 2 3" to f, and "drausst bist du" to g.
the position of the arguments to init are not arbitrary. the argument parses does not try to check the signatures of the functions to be called to determine the number of arguments. This won't be cheap, the handling of "args" and default values makes it unclear what to pass as argument...
-gustaf
Kristoffer Lawson schrieb:
This is with XOTcl 1.3.6, but I couldn't find if 1.3.8 fixes it. The following code does not appear to work as expected:
package require XOTcl namespace import xotcl::*
Class A
A instproc init {test} { puts "init: $test" }
A instproc foo {text} { puts "foo: $text" }
A instproc bar {text} { puts "bar: $text" }
A new "on taas" -foo jou -bar blah A new -foo jou -bar blah "on taas"
The first will work, but the latter will not. The error is:
wrong # args: should be "bar text" ::xotcl::__#1 ::A->bar ::xotcl::__#1 ::xotcl::Object->configure ::A ::xotcl::Class->create ::A ::xotcl::Class->new invoked from within "A new -foo jou -bar blah "on taas"" (file "dashCreateTest.tcl" line 23)
/ http://www.fishpool.com/~setok/
Xotcl mailing list Xotcl@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl