in reply to Optional quotes: to use or not to
Whereas my own viewpoint would be quite definite: “never use barewords!”
A bareword is a string literal that doesn’t look like one. I believe very strongly that everything in the source-code of a computer program should look, to a human being, like what it actually is to the compiler. If that means typing two extra characters and pressing the Shift key twice, c’est la guerre. We aren’t putting source code on paper tape anymore.
Now, let me tell you why. Remember, from my Meditations thread, that “I see dead projects.” The software was abandoned by a programmer or team that did very sloppy, unsupervised work, e.g. before their visa-time ran out. In one such case, many days were spent looking for what turned out to be ... “an omitted dollar-sign.” foo instead of $foo, buried deeply in a mountain of shit source code. A bareword, meant to be a variable-reference, but acceptable to the Perl compiler.
Unlike most other languages today (JavaScript being the most notable and therefore most egregious exception), Perl is very permissive. It likes to assume that you meant exactly what you say, that you never make a tpyographic error, never use the wring word, put never words in the order wrong. That source is meant to be taken at face-value exactly as writ, if possible. The defense against this is coding-standards, and to me this is an important one.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Optional quotes: to use or not to
by 1nickt (Canon) on Jul 10, 2015 at 12:42 UTC | |
by u65 (Chaplain) on Jul 10, 2015 at 14:38 UTC | |
|
Re^2: Optional quotes: to use or not to
by hurricup (Pilgrim) on Jul 10, 2015 at 12:35 UTC |