[Xotcl] non positional argument

vitick at gmail.com vitick at gmail.com
Tue Oct 26 23:23:01 CEST 2010


Is it possible to have a non-positional argument that is optional and its variable is only set when it is present as the argument to the method. Otherwise, it is ignored, no error. 
Basically, I want it behave like an option to the method but without specifying any value. Example:

myobj method m {-test} {
    if {[info exists test]} {
        puts "test exists";
    } else {
        puts "test does not exist";
    }

myobj m;#test does not exist 
myobj m -test;#test exists

Or, it can even be a boolean, set to 1 if it was specified and set to 0 if not. That would be even better, shorter code. 

Thank you


More information about the Xotcl mailing list