[Xotcl] incorrect example for non positional arguments

John McGlaughlin jmcglaug at cisco.com
Mon Mar 7 19:47:00 CET 2005


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://alice.wu-wien.ac.at/pipermail/xotcl/attachments/20050307/a657733f/attachment.html


More information about the Xotcl mailing list