Artifacts Associated With Ticket 1537233fffffffff
Ticket change [b1afffd69a] (rid 98192) by ctasada on 2006-08-09 08:57:41:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hi again guys, I've seen a feature request that can be related (1106138) so probably it's a known "feature" of the switch command. Anyway I find it quite strange. Here is the script that shows the actual problem: # Create some variables and assign numbers to them set one 1 set two 2 set three 3 set value 2 switch -- $value { $one {puts 1} $two {puts 2} $three {puts 3} default {puts "$value is unknown"} } % 2 is unknown switch -- $value { 1 {puts 1} 2 {puts 2} 3 {puts 3} default {puts "$value is unknown"} } % 2 As you can see looks like is not doing the variable substitution. Googling a bit I found this solution: switch -- $value [list\ $one {puts 1}\ $two {puts 2}\ $three {puts 3}\ default {puts "$value is unknown"}\ ] % 2 Which works, but is quite dirty. Should be considered a bug? - foundin initialized to: "obsolete: 8.5a4"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "ctasada"
- subsystem initialized to: "18. Commands M-Z"
- title initialized to: "Switch doesn't variable substitution"
- type initialized to: "Bug"
Ticket change [885607f1fb] (rid 131852) by dkf on 2006-08-09 17:04:23:
- closedate changed to: "2006-08-09T10:04:23"
- closer changed to: "dkf"
- icomment:
Logged In: YES user_id=79902 It's not a bug. It's just Tcl's standard quoting rules, and everything *has* to be this way for reasons that are rather deeply embedded in the language's basic philosophy. But for this case, the other form of input to the [switch] command is probably useful. You are aware that what you wrote could also be (wholly equivalently) written like this: switch -- $value \ $one {puts 1} \ $two {puts 2} \ $three {puts 3} \ default {puts "$value is unknown"} Hope this helps. - login: "dkf"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- username: "dkf"
Ticket change [949075b722] (rid 106007) by ctasada on 2006-08-09 17:18:29:
- icomment:
Logged In: YES user_id=340696 Ok, I though you would say it ;) Anyway would be nice to have this kind of feature is Tcl ;) Thanks a lot.
- login: "ctasada"
- mimetype: "text/plain"
- username: "ctasada"
- icomment: