Consensus on the kdelibs coding style

Lucas Murray admin at undefinedfire.com
Sun Jul 6 16:01:39 BST 2008


On Sun, Jul 6, 2008 at 9:38 PM, Kelly Miller <lightsolphoenix at gmail.com> wrote:
>
> On July 5, 2008 9:41:23 am Lubos Lunak wrote:
>> - "4 spaces, no tabs" - this appears to be the most used style in kdelibs,
>> and other options don't seem to have big advantages
>
> Can someone explain to me what's so evil about tabs?  Personally, I hate
> stumbling across spaced code indents, because they're horribly inflexible,
> can't be resized at all, and require the programmer in question to remember to
> hit the space key X times for an indent.
>

Tabs are okay in most cases, however when they are used to align
multiple lines by mixing in spaces with them things get a little messy
as not everyone has their tab size set to the same amount. Some people
use the default 8, a large amount use 4 and a few even use 2 character
indents. Using spaces completely removes this problem. Take for
example the following for-loop, I have repeated twice to so what it
would look like if the person that wrote it used 4 character indents
while the other uses 8:

for( ToplevelList::ConstIterator it = windows.begin();
     it != windows.end();
     ++it )
{
    // 4-character tab, for-loop arguments are aligned
}

for( ToplevelList::ConstIterator it = windows.begin();
         it != windows.end();
         ++it )
{
        // 8-character tab, out of alignment
}

As for pressing the space bar: Any decent editor these days can
automatically place the required amount of spaces when the tab key is
pressed to bring it into alignment with other lines.




More information about the kde-core-devel mailing list