Passing list to Tcl procedure

前端 未结 3 794
日久生厌
日久生厌 2021-02-13 02:56

What is the canonical way to pass a list to a Tcl procedure?

I\'d really like it if I could get it so that a list is automatically expanded into a variable number of arg

3条回答
  •  走了就别回头了
    2021-02-13 03:04

    It might be useful to note that passing your command to catch will also solve this problem:

    set a {b c}
    if [catch "myprocedure option1 option2 $a"] {
        # handle errors
    }
    

    This should probably only be used if you want to handle errors in myprocedure at this point in your code so that you don't have to worry about rethrowing any errors that get caught.

提交回复
热议问题