[OT] Spaces/tabs (Was: simple display (from: GUI library for D))
spir
denis.spir at gmail.com
Tue Apr 12 02:02:30 PDT 2011
On 04/12/2011 05:19 AM, Jonathan M Davis wrote:
> Using only spaces and no tabs avoids the entire issue
spaces <--> tabs works as fine
Why are programmers so blindly unfair when discussing this point?
> and is one of the major reasons (if not _the_ major reason) why it is incredibly common for coding
standards to require spaces and prohibit tabs. Obviously, you _can_ use tabs if
you're careful - especially if you're the only programmer involved - but it's
just simpler to disallow tabs when you're dealing with a group of developers.
I guess the true reason why spaces are required in guidelines is a mix of
conformism and "virality". At one point in time, people started to face the
issue, thay had to make a choice for coding standard in language libs,
corporation code, school/university works, etc. They chose spaces because, at
that time, most people used spaces and did not want to change. Then, even more
programmers get used to use spaces and don't want to change, so that new coding
standards are forced to enforce spaces, and so on...
There is no, and there has never been any, logical reason for this choice.
There cannot be, in fact:
1. Tabs properly separate code content from view,
2. and respect each reader's preference.
In addition to those main reasons, they have a few nice side-effects:
* No indent width issue (!),
* 1 tab <--> 1 indent level conceptually,
* deletion is 1 key press, even with stupid editors.
A drawback is one cannot directly have different indent levels, for instance to
indent collection contents more, or less, than blocks of code. This can also be
considered an advantage; and is simply solved by using... spaces ;-)
void f () {
-> while (true) {
-> -> table = [
-> -> .."aaa" : 1,
-> -> .."bbb" : 2,
-> -> .."ccc" : 3,
-> -> ];
-> -> auto a = this(table);
-> -> if (! a) break;
-> }
}
(yes, the example is stupid)
Denis
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d
mailing list