Quote:
Originally Posted by pan64
Superfluous quotes make the code unnecessarily noisy. I do not like them, so I use them only when they really have meaning.
|
That's not an unreasonable position, but it is one that depends on experience. I take the stance here that new coders should get into the habit of doing it safely first. Once they really know what they are doing they can make their own decisions.
Besides, eliminating
all superfluous syntax is not always the best option. Keeping your code clear, consistent, and readable is usually more important than simple terseness. There are times when I've even put unnecessary quotes around unbroken string literals (in array setting brackets, say) just because they matched the other entries around them that did need them. It helped make it clear at a glance that all the values were part of the same group and type of data.
Quote:
Originally Posted by leib
thanks david, and thanks for the links. i just got in the habit of ${var} and try to do that when i can. i know it is not required, but i feel better safe then sorry.
|
Well, again, the brackets do nothing outside of the situations I mentioned before. I went through a short period where I put them everywhere too, and thoroughly regretted it later when I went back to update some old scripts I had written. I felt that the code was uncomfortable to read and edit, to say the least. But it is your choice.
I guess my point is that there's a difference between useful consistency and pointless consistency. I consider quotes to be of the former, for the most part, as they can often have a real effect on the code, and bracketed variables the latter, as they don't.