It involves TCL 8.6, and is derived from answer I got on issue Nitpicking: Tcl storing in a variable or not, for speed, in procedures So, consider this code:
proc me1 { in1 in2 } {
if { $in1 > $in2 } {
return [ k $in1 ]
} else {
return [ k2 $in2 $in1 ]
}
}
proc me { in1 in2 } {
expr { $in1 > $in2 ? [ k $in1 ] : [ k2 $in2 $in1 ] }
}
proc k {in1 } {
puts "returnal should be \"0${in1}\""
return "0${in1}"
}
proc k2 { in1 in2 } {
return "01${in1}00 ${in2}"
}
It would appear that procs me and me1 should return the same value (they actually do, if similar code was written in Ruby or PERL). This is decidedly not the case in TCL. Consider now the output of me and m1 (remember that if k is called, the "expected return" is printed out):
puts [ me 23 0 ]
>returnal should be "023"
>19
puts [ me1 23 0 ]
>returnal should be "023"
>023
So, expr and/or the ternary are doing something "under the hood", by processing the "returnal". The question are:
1. What does it do?
2. How can it be disabled?