Web site hosting and cheap domain name registration services
  

 Home

PEAR Manual
PrevChapter 6. FAQ - Frequently Asked QuestionsNext

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

Answer written by Stig Bakken.

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:

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:

printf("%s",
           $arg);

Likewise, consider this code written with 8-space tabs:

    if ($foo &&
        $bar) {
    }

If viewed in a 4-space-tab editor, it will look like this:

    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.


PrevHomeNext
What licenses are allowed in PEAR/PECL?UpIs there a tool to help PEAR manual translators to track files changes?

 

  

 

© 2002-2004 Active-Venture.com Website Hosting Service

 

Disclaimer: This documentation is provided only for the benefits of our web hosting customers.
For authoritative source of the documentation, please refer to http://pear.php.net/manual/

Recommended Resources: 

Cheap domain registrar : domain name registration and domain transfer services Cheap domain registration or register domain name from $5.95