Hullo -
I found a little bug with non-positional arguments & regular default arguments in version 1.3.1. Consider the following example:
Object o o proc foo {{-a apple}} {{b banana}} { puts "FOO: [info locals]" puts "a: $a b: $b" }
We have a method "foo" that has one optional argument, "b", and one option non-positional argument, "a". Now consider the possible ways to call this method: o foo o foo -a ack o foo bar o foo -a ack bar
In the cases where we let "b" use it's default value of "banana", we will get the error: wrong # args: should be {{b banana}}
In the cases where we specify "b", we will find that "b" is not valid variable in method scope. In fact, what is happening is that the variable "{b banana}" is being set. Should we try to use "$b", we will get the error: can't read "b": no such variable
It would seem that ::xotcl::interpretNonPositionalArgs does not take in to account for default values on regular type arguments.
Regards. -- bryan
Hi Bryan,
thanks for reporting this bug. I have fixed it and updated the snapshot at:
http://wi.wu-wien.ac.at/~uzdun/resources/xotcl-1.3.2.tar.gz
could you please check whether this one works as expected?
Uwe
Schofield, Bryan (GE Transportation) wrote:
Hullo -
I found a little bug with non-positional arguments & regular default arguments in version 1.3.1. Consider the following example:
Object o o proc foo {{-a apple}} {{b banana}} { puts "FOO: [info locals]" puts "a: $a b: $b" }
We have a method "foo" that has one optional argument, "b", and one option non-positional argument, "a". Now consider the possible ways to call this method: o foo o foo -a ack o foo bar o foo -a ack bar
In the cases where we let "b" use it's default value of "banana", we will get the error: wrong # args: should be {{b banana}}
In the cases where we specify "b", we will find that "b" is not valid variable in method scope. In fact, what is happening is that the variable "{b banana}" is being set. Should we try to use "$b", we will get the error: can't read "b": no such variable
It would seem that ::xotcl::interpretNonPositionalArgs does not take in to account for default values on regular type arguments.
Regards. -- bryan
Xotcl mailing list - Xotcl@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl