如何将包含更多参数的字典传递到tcl中的进程中?

如何将包含更多参数的字典传递到tcl中的进程中?,tcl,Tcl,现在我想通过这样的测试: proc test {a b c } { puts $a puts $b puts $c } set test_dict [dict create a 2 b 3 c 4 d 5] 如何进行测试仅选择dict中具有相同参数名称的三个元素(键)。预期产出应为: test $test_dict 因为它在字典中选择了abc,而不是d。我该怎么做?我看到一些代码是这样的,但我无法使其工作。我认为您应该使用dict get: 2 3

现在我想通过这样的测试:

proc test {a b c } {
       puts $a
       puts $b
       puts $c
}
set test_dict [dict create a 2 b 3 c 4 d 5]
如何进行
测试
仅选择dict中具有相同参数名称的三个元素(键)。预期产出应为:

test $test_dict

因为它在字典中选择了
abc
,而不是
d
。我该怎么做?我看到一些代码是这样的,但我无法使其工作。

我认为您应该使用
dict get

2
3
4
编辑: 另一种变体是将
dict与
一起使用:

proc test {test_dic} {
  puts [dict get $test_dic a]
  puts [dict get $test_dic b]
  puts [dict get $test_dic c]
}

set test_dict [dict create a 2 b 3 c 4 d 5]
test $test_dict

但是
test
仍然获取一个列表。

我看到参数列表包含单个元素,而不是列表,但在调用时,只有一个字典被传递到函数中。我认为作者在将字典传递到参数列表时使用了一些技术来扩展字典。或者
dict with test_dict{test$a$b$c}
(但这会污染调用者)。编辑:
test_dic
成为
test_dict
proc test {test_dic} {
  dict with test_dic {
    puts $a
    puts $b
    puts $c
  }
}

set test_dict [dict create a 2 b 3 c 4 d 5]
test $test_dict