BackgroundTIP #144 Argument Expansion Syntax [1] (and the earlier TIP #103 Argument Expansion Command [2]) proposes to add syntax to Tcl to perform argument expansion in a safe and efficient manner.For example, instead of having to write:
eval [linsert $args 0 exec $program]The TIP would allow one to say:
exec $program {}$argswhere the leading {} indicates that the remainder of the word shall be parsed as a list (after applying the usual substitution rules), and each element of the list is passed as a separate argument to the command.Naturally, there has been a great deal of discussion about what syntax should be used to indicate argument expansion. The two most popular options seem to be {} and ` (backquote).The main advantage of the {} syntax is that it can be added to Tcl 8.5 without breaking backwards-compatibility, as such usage is currently a syntax error. Any other option would have to wait until Tcl 9.0.A similar poll was conducted on the tcl-core mailing list. The result is on the Argument Expansion Poll Summary page.PollThe purpose of this poll is to get a feel for the Tcl community's preferences regarding the proposed syntaxes. The poll is in two parts: the first asks which syntax would be preferable if backwards compatibility were not an issue. The second asks if the backwards-compatible syntax would be acceptable if it meant the feature could be introduced earlier.Please vote by signing your name or initials after the proposed option.Discussion moved to DISCUSSION: Argument Expansion SyntaxPart 1: which syntax do you prefer?Option 1: leading {}: Vince, RS, Roy Terry, Jeffrey Hobbs, EB, Andreas Leitgeb, JMNOption 2: leading `: Joe English, ramsan, SO, US, MC, NEM, Heiner Marxen, FW, Philipp RoesslerOption 3: other (please specify):
- leading {expand} DGP, Daniel Steffen, MS, KBK, Peter Spjuth, de, Donald Arseneau, JBR
- $$foo and $[foo]: Lars H
- [expand <whatever you want expanded>] If someone can do it: Steve Redler IV, MAK, Peter De Rijk, TR, Jacob Levy, TP, davidw, Salvatore Sanfilippo, PT, Joe Mistachkin, TFW, WW
- ^^$foo and ^^[foo] : Setok
- Added functionality to Tcl that allows "macro" commands: commands can edit the calling command line. Dangerous in a semi-Tclish fashion. F.ex. file join [expand $MyList] : Setok Scott Gargash, Joe Mistachkin (see lconvert), MAK (Well, I'm confused by the different "expand" options. See [3]: same idea, but simpler than lconvert.)
- paired backquotes meaning eval and expand (see Discussion: Argument Expansion Syntax): Scott Gargash
- add switch to eval to control expansion of args. Larry Smith, Joe Mistachkin
eval arg1 arg2 arg3 arg4 arg5 ; same as before - expands all args eval -only { arg4 } ; expands arg 4 eval -only { arg1 to arg3 } ; expand arg 1 to arg3 eval -- -only arg2 ; -- turns off switch processing, -only just another arg to expand
- Just use a postfix * As in cmd $*var or [*cmd] , has small impact on backwards compatibility. This syntax places expansion back at the parser backend where it has already detected special chars of either $ or [. PWQ MSW (although I prefer ruby's *[cmd] or *$var) Brent Welch