[Xotcl] Bug! 1.3.1 Nonpositional args and default arguments values

Schofield, Bryan (GE Transportation) Bryan.Schofield at trans.ge.com
Tue Sep 14 19:08:32 CEST 2004


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




More information about the Xotcl mailing list