PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Tabs vs. Spaces

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PEAR Forum Forum Index -> PEAR FAQ's
View previous topic :: View next topic  
Author Message
primeminister
Site Admin


Joined: 16 Apr 2006
Posts: 95
Location: Netherlands

PostPosted: Tue Apr 18, 2006 12:06 pm    Post subject: Tabs vs. Spaces Reply with quote

Why does the PEAR coding standard insist on space-only indentation?

Last edited by primeminister on Tue Apr 18, 2006 12:12 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
primeminister
Site Admin


Joined: 16 Apr 2006
Posts: 95
Location: Netherlands

PostPosted: Tue Apr 18, 2006 12:07 pm    Post subject: Reply with quote

Using spaces and avoiding tabs is the only way to ensure that a piece of code is rendered consistently in all editors and viewers. Many editors render tabs as 4 spaces, and a lot of editors, terminal programs and utilities render tabs as 8 spaces. Example:
Code:
printf("%s",
       $arg);

Here, there are 7 spaces before "$arg". If this code was written in an editor with 4-space tabs, it would store it as one tab and three spaces. Now, if another developer edits the same file in an editor with 8-space tabs, it will look like this:
Code:
printf("%s",
           $arg);

Likewise, consider this code written with 8-space tabs:
Code:
    if ($foo &&
        $bar) {
    }

If viewed in a 4-space-tab editor, it will look like this:
Code:
    if ($foo &&
    $bar) {
    }

In a community like PEAR where people use lots of different systems and editors, using tabs simply doesn't work. People will end up doing whitespace commits fixing rendering in their editor, while breaking it for others. With only spaces it will look the same to everyone.

Jamie Zawinski has written a piece on the subject too.

There is also a tool called Astyle which can help you convert your code to the appropriate style.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PEAR Forum Forum Index -> PEAR FAQ's All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement