Tcl [list abc] vs {abc} is there a difference and in what context?

I play with Tcl and found several scenarios where it [list a b c]is interchangeable with {a b c}. What is the preferred method and where [list a b c]does it not match the behavior {a b c}?

+3
source share
2 answers
% set lista [list a b c]
a b c
% set listb {a b c}
a b c
% set b {1 2 3}
1 2 3
% set lista [list a $b c]
a {1 2 3} c
% set listb {a $b c}
a $b c

When you build a list using literals, these two forms are equivalent. When you use variables, the form [list ...]will expand the variable before placing it on the string, and the form {...}will not.

, {...} , , ; $ . [list ...] , . , , , , , .

+7

( , , ). ( bta).

, , . !

, {…} "…", . , tcom Tcl/Java (.. Jacl TclBlend), , Tcl . , "" , ; Tcl_Obj, , ( "" Tcl), COM- Java , , . [list …] ( , lindex ) , .

Tcl, , , , , . , ( ?), [list] , ( ).

, , .

, , . ( after, fileevent trace, , .) , list ( - , ), , , Tcl script , , . , , .

+5

Source: https://habr.com/ru/post/1759177/


All Articles