Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 1
    \$\begingroup\$ I think you can make it better by renaming if and rename after the loop. In the second version, you should also make proc an exception. \$\endgroup\$
    – jimmy23013
    Commented Oct 20, 2015 at 7:08
  • \$\begingroup\$ @jimmy23013 Hmm.. technically you should be right but that code snippet works with the current version of tcl even when proc appears in the list before puts. Technically the code should also work without rename but built-in commands seem to be protected otherwise. Not sure what's going on but the code is tested and works as advertised. \$\endgroup\$
    – slebetman
    Commented Oct 20, 2015 at 7:24
  • \$\begingroup\$ @jimmy23013: OK. Code now works without needing to call rename. It was brainfart on my part - I forgot to exclude proc. \$\endgroup\$
    – slebetman
    Commented Oct 20, 2015 at 7:27
  • \$\begingroup\$ I decided not to rename if because being able to do if alone is pretty much useless if you want to generate output. \$\endgroup\$
    – slebetman
    Commented Oct 20, 2015 at 7:28
  • \$\begingroup\$ Of course you don't need to rename them. But this is not code-golf. I just thought renaming them may (or may not) make this answer looks better. \$\endgroup\$
    – jimmy23013
    Commented Oct 20, 2015 at 7:32