I am having difficulty getting non-positional arguments to behave correctly with args. The simple example below shows what I have found. This does not appear to be appropriate behavior. Am I doing something wrong?
Object obj
obj proc pr1 { {-npos default} args } {
puts "npos: $npos"
puts "args: $args"
}
## This works:
obj pr1 a
npos: default
args: a
## As does this:
obj pr1 -npos 3 a
npos: 3
args: a
## But this does not:
obj pr1 -npos 3
npos: 3
args: -npos 3
## I expected args to be {}, but instead it contains the non-positional
parameter
Thanks for any insight you can provide.
-Kurt Stoll
Hi Kurt,
uff, this was mean: i did take me a while that the dashes from your examples are not minus signs, but different chars (hex e2 80 93; compare "-" with "-").
however, the bug occurs as well with the minus sign, so i expect these dashes were introduced by your mail client.
below is a patch for xotcl-1.3.9, that will be included in the forthcoming xotcl 1.4.0
-gustaf
========================================================= --- generic/xotcl.c-orig 2005-12-09 10:43:19.000000000 +0100 +++ generic/xotcl.c 2006-02-17 18:44:20.000000000 +0100 @@ -10437,7 +10437,12 @@ ordinaryArgsCounter++; } } - if (!argsDefined) { + if (argsDefined) { + if (ordinaryArgsCounter == 0) { + Tcl_SetVar2(in, "args", 0, "", 0); + } + } else { + /* !argsDefined */ if (ordinaryArgsCounter != ordinaryArgsDefc) { /* we do not have enough arguments, maybe there are default arguments for the missing args */
=========================================================
Kurt Stoll schrieb:
I am having difficulty getting non-positional arguments to behave correctly with args. The simple example below shows what I have found. This does not appear to be appropriate behavior. Am I doing something wrong?
Object obj
obj proc pr1 { {-npos default} args } {
puts "npos: $npos" puts "args: $args"
}
## This works:
obj pr1 a
npos: default
args: a
## As does this:
obj pr1 -npos 3 a
npos: 3
args: a
## But this does not:
obj pr1 -npos 3
npos: 3
args: -npos 3
## I expected args to be {}, but instead it contains the
non-positional parameter
Thanks for any insight you can provide.
-Kurt Stoll
Xotcl mailing list Xotcl@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl