Re: puts variable without quoting




slebetman@xxxxxxxxx wrote:
On Sep 13, 6:33 am, John Kelly <j...@xxxxxxxxxxxx> wrote:
On Wed, 12 Sep 2007 17:20:41 -0500, Bruce Hartweg

<no.spam....@xxxxxxxxxxx> wrote:
I think the OP understood the quoting aspect to make a single
arg to a command, and saw that a single variable was also a single word
but was wondering about performance of quoting it anyway.
For a standpoint of style, it might seem preferable to always use
quotes with a puts string.

Actually I disagree with this. For a standpoint of style:

puts $something

looks better to me than

puts "$something"

There may be some who would think that quoting in "" signifies a
string making the intentions clearer but this misunderstands the
nature of Tcl:
1. everything is a string anyway
No not really. I wish we would all stop chanting this out-dated
mantra. It just doesn't seem very helpful. True most values can
be usefully represented as strings. But notice this catch for
someone who wants to take the EIS on face value:
if {joe eq mike} {puts wow}
==> syntax error in expression "joe eq mike": variable references require preceding $
So is it a good idea to say " *everything* is a string anyway"?

2. "quotes" don't singnify strings in tcl, instead they allow the
parser to group multiple words into a single "word" just like {braces}
Yes. Nor do {} signify list as many seem to believe.

In addition, for puts-ing single variables, you'll notice that most
Tclers omit the "$quotes" as a matter of style. So stylewise the
standard is to not use "".

.



Relevant Pages

  • Re: Question about quoting style.
    ... qaz="$baz $foo and grill" # Interpolation needs double quotes. ... of quoting should be employed? ... Where it makes a difference is that "triple-quoted" string literals ...
    (comp.lang.python)
  • Re: String Problems?
    ... Carter Davis wrote: ... puts to output a string, the string is in quotes. ... If you do have the same problem with puts, please show the code using puts ...
    (comp.lang.ruby)
  • Re: puts variable without quoting
    ... and saw that a single variable was also a single word ... but was wondering about performance of quoting it anyway. ... quotes with a puts string. ...
    (comp.lang.tcl)
  • Re: puts variable without quoting
    ... and saw that a single variable was also a single word ... but was wondering about performance of quoting it anyway. ... quotes with a puts string. ...
    (comp.lang.tcl)
  • RE: Calling a PostgreSQL function via DBI
    ... What exactly do you believe adding the double quotes does to alter the ... string value stored in $arg1? ... And again, in now a third attempt to clarify to Will, nowhere did I ... state that double quoting around a variable in PERL, ...
    (perl.dbi.users)