5 ms·
#!/usr/bin/env tclsh puts $argv I kinda wanted to stop reading after this example. It feels dishonest to start with an example for which there is a builti
by greenpeas 3y ago
#!/usr/bin/env tclsh
puts $argv
I kinda wanted to stop reading after this example. It feels dishonest to start with an example for which there is a builtin. Why didn't you show instead how to output arguments joined by a comma or some other separator instead of space.
If I were to update the Go or Python examples to use another separator, it'd be just a 1-2 character change, whereas for Tcl I have no idea how that would look.
- shrubble 3y agoThe author is following examples given in a book, however.
- greenpeas 3y agoOh, I missed that. I guess it's alright then. I thought they chose this particular example to "showcase" Tcl by comparison.
- AshamedCaptain 3y agoFunnily neither version gives the correct result when you have arguments with spaces, e.g. for "-v 5" -d , the tcl one will print {-v 5} -d as a consequence of how tcl represents lists.
- pwg 3y agoThe author should have done: puts [join $argv] to avoid that little issue. Doing "puts $argv" triggers Tcl's output of "lists" in a special format that allows the list to be parsed from the text again at a later time.
- pwg 3y ago> Why didn't you show instead how to output arguments joined by a comma or some other separator instead of space. The Tcl variant to output "comma" as separator (note -- this is not "CSV"). puts [join $argv ,] If you wanted "comma space" you'd do: puts [join $argv ", "] If you actually wanted "CSV" then it would be (assuming tcllib is installed): package require csv puts [csv::join $argv]