View · Search · Index
No registered users in community xowiki
in last 10 minutes

[Xotcl] incorrect example for non positional arguments

From: John McGlaughlin <jmcglaug_at_cisco.com>
Date: Mon, 07 Mar 2005 13:47:00 -0500

The following examples in tutorial cause errors

Object o
 o proc y {-a {-b {1 2 3}} x y} {
     puts "$a $b $x $y"
 }

Class P
 P instproc y {-a:required {-b:boolean true}} {
     puts "$a $b"
 }


Thanks to Ben Thomasson for correcting this for me
the code should be

ALSO notice that one example is incorrect for -b passing a string 4 5 needs to be bound {4 5}

(tcl) 165 % o proc y {-a {-b {1 2 3}}} { x y } {
   puts "$a $b $x $y"
}
(tcl) 166 % o y -b 4 5 -a 1 3 4
wrong # args: should be { x y }
(tcl) 167 % o y -b {4 5} -a 1 3 4
1 4 5 3 4
(tcl) 168 % o y -a 1 3 4
1 1 2 3 3 4
(tcl) 169 % o y -a 1 -- -b -c
1 1 2 3 -b -c
(tcl) 170 %


(tcl) 174 % P instproc y {-a:required {-b:boolean true}} {} {
     puts "$a $b"
 }
(tcl) 175 % P p
::xotcl::p
(tcl) 176 % p y -a 1 -b 0
1 0