Thread: AW: [HACKERS] LONG varsize - how to go on (pgindent)

AW: [HACKERS] LONG varsize - how to go on (pgindent)

From
Zeugswetter Andreas SB
Date:
> > Bruce doesn't want to do that, and I doubt anyone will 
> force the issue
> > over his veto.  But it would be nice to be able to do a 
> pgindent run;
> > there's a lot of new code in this release.
> 
> I hope I didn't "veto" it.  I just wanted to mention my reasons, and
> look for other people to vote too.  I have Vince, Peter, and Tom who
> want 8-space tabs and 4-space indents.  Because the old standard was
> voted on by many more people, I need to hear additional votes 
> to change
> our standard.

I think the idea at that time was also, that with a tab only setup people
can 
look at the code with 2 space, 3 space and 4 space indents, whatever suits 
them best.

I like the current setup. Our company uses the same.

Most Programmers editors (and vi) can handle the 4 space tabs perfectly.
The pager less handles them also.

Andreas


Re: AW: [HACKERS] LONG varsize - how to go on (pgindent)

From
Vince Vielhaber
Date:
On Tue, 21 Dec 1999, Zeugswetter Andreas SB wrote:

> 
> > > Bruce doesn't want to do that, and I doubt anyone will 
> > force the issue
> > > over his veto.  But it would be nice to be able to do a 
> > pgindent run;
> > > there's a lot of new code in this release.
> > 
> > I hope I didn't "veto" it.  I just wanted to mention my reasons, and
> > look for other people to vote too.  I have Vince, Peter, and Tom who
> > want 8-space tabs and 4-space indents.  Because the old standard was
> > voted on by many more people, I need to hear additional votes 
> > to change
> > our standard.

Whoa.  Wait.  Timeout!  If I ever said I liked 8 space anythings I musta
mistyped, been half asleep, not paying attention or something.  I'm 
flexible, the only thing I want is a noticable indent and tab; I don't
really care if it's anywhere between one and four, but eight is too many.
Actually the only comment I remember making is that I always preferred
blocks like this:
   if( ) {// do something   }

which I guess isn't very popular.  I did, however, utilize the xemacs
indent thing that Tom Lane posted here a couple weeks ago.  Thanks Tom!

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH    email: vev@michvhf.com    http://www.pop4.net
128K ISDN - $24.95/mo or less; 56K Dialup - $17.95/mo or less www.pop4.net       Online Campground Directory
http://www.camping-usa.com     Online Giftshop Superstore    http://www.cloudninegifts.com
 
==========================================================================





Re: AW: [HACKERS] LONG varsize - how to go on (pgindent)

From
Tom Lane
Date:
Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at> writes:
> I think the idea at that time was also, that with a tab only setup
> people can look at the code with 2 space, 3 space and 4 space indents,
> whatever suits them best.

Not really.  If the code still looked OK at different tab widths, people
wouldn't be complaining.  A fairly typical example is
   if (root->query_pathkeys == NIL ||       pathkeys_contained_in(root->query_pathkeys,
final_rel->cheapestpath->pathkeys))  {       root->query_pathkeys = final_rel->cheapestpath->pathkeys;
 

which is really

<tb>if (root->query_pathkeys == NIL ||
<tb><tb>pathkeys_contained_in(root->query_pathkeys,
<tb><tb><tb><tb><tb><tb><tb>  final_rel->cheapestpath->pathkeys))
<tb>{
<tb><tb>root->query_pathkeys = final_rel->cheapestpath->pathkeys;

so at 8-space tab expansion it looks like
       if (root->query_pathkeys == NIL ||               pathkeys_contained_in(root->query_pathkeys,
                                   final_rel->cheapestpath->pathkeys))       {               root->query_pathkeys =
final_rel->cheapestpath->pathkeys;

and in fact at any tab spacing other than 4, it will look bizarre.

Things get even worse for declarations and comments in the right margin:

typedef struct Unique
{   Plan        plan;           /* noname node flattened out */   Oid         nonameid;   int         keycount;   char
    *uniqueAttr;     /* NULL if all attrs, or unique attribute                                * name */   AttrNumber
uniqueAttrNum; /* attribute number of attribute to select                                * distinct on */   UniqueState
*uniquestate;
} Unique;

is really

typedef struct Unique
{
<tb>Plan<tb><tb>plan;<tb><tb><tb>/* noname node flattened out */
<tb>Oid<tb><tb><tb>nonameid;
<tb>int<tb><tb><tb>keycount;
<tb>char<tb>   *uniqueAttr;<tb><tb>/* NULL if all attrs, or unique attribute
<tb><tb><tb><tb><tb><tb><tb><tb> * name */
<tb>AttrNumber<tb>uniqueAttrNum;<tb>/* attribute number of attribute to select
<tb><tb><tb><tb><tb><tb><tb><tb> * distinct on */
<tb>UniqueState *uniquestate;
} Unique;

so at 8-space tabs it looks like

typedef struct Unique
{       Plan            plan;                   /* noname node flattened out */       Oid                     nonameid;
     int                     keycount;       char       *uniqueAttr;         /* NULL if all attrs, or unique attribute
                                                             * name */       AttrNumber      uniqueAttrNum;  /*
attributenumber of attribute to select                                                                * distinct on */
    UniqueState *uniquestate;
 
} Unique;

and again, it's not going to look right at any tab width except 4.

> Most Programmers editors (and vi) can handle the 4 space tabs perfectly.

Anyone who can't persuade his editor to show tabs as 4 spaces isn't
going to be contributing to Postgres, because he's not going to find
the code readable.  So it's not surprising that the population of this
list considers it a non-problem; natural selection has eliminated the
people who might complain.  But I'd like to get rid of that barrier
to new contributors.  How many potential contributors have we lost
because they took one look at the code and decided it was too ugly
even to think of working with?

If changing the tabs is too radical, it'd at least be a good idea to add
a section to the Developers' FAQ explaining how to set up all the common
editors for Postgres.  I can contribute a recipe for Emacs, but I have
no idea how to do it for vi or anything else...
        regards, tom lane


Re: AW: [HACKERS] LONG varsize - how to go on (pgindent)

From
wieck@debis.com (Jan Wieck)
Date:
> If changing the tabs is too radical, it'd at least be a good idea to add
> a section to the Developers' FAQ explaining how to set up all the common
> editors for Postgres.  I can contribute a recipe for Emacs, but I have
> no idea how to do it for vi or anything else...

    In ~/.exrc you need:

    set tabstop=4
    set sw=4

    That's  all. But I like 8-spaced tabs anyway. It's a very old
    de-facto standard (I think  CP/M  already  treated  TAB  this
    way),  so  having  something different is definitely what Tom
    said - a reason for potential contributors NOT do contribute.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#========================================= wieck@debis.com (Jan Wieck) #

Re: AW: [HACKERS] LONG varsize - how to go on (pgindent)

From
Bruce Momjian
Date:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> 
> > > Bruce doesn't want to do that, and I doubt anyone will 
> > force the issue
> > > over his veto.  But it would be nice to be able to do a 
> > pgindent run;
> > > there's a lot of new code in this release.
> > 
> > I hope I didn't "veto" it.  I just wanted to mention my reasons, and
> > look for other people to vote too.  I have Vince, Peter, and Tom who
> > want 8-space tabs and 4-space indents.  Because the old standard was
> > voted on by many more people, I need to hear additional votes 
> > to change
> > our standard.
> 
> I think the idea at that time was also, that with a tab only setup people
> can 
> look at the code with 2 space, 3 space and 4 space indents, whatever suits 
> them best.
> 
> I like the current setup. Our company uses the same.
> 
> Most Programmers editors (and vi) can handle the 4 space tabs perfectly.
> The pager less handles them also.

Wow, that's something I never thought of.  By using only tabs, they can
be configured as any size in the editor.  Good point.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: AW: [HACKERS] LONG varsize - how to go on (pgindent)

From
Bruce Momjian
Date:
> > > I hope I didn't "veto" it.  I just wanted to mention my reasons, and
> > > look for other people to vote too.  I have Vince, Peter, and Tom who
> > > want 8-space tabs and 4-space indents.  Because the old standard was
> > > voted on by many more people, I need to hear additional votes 
> > > to change
> > > our standard.
> 
> Whoa.  Wait.  Timeout!  If I ever said I liked 8 space anythings I musta
> mistyped, been half asleep, not paying attention or something.  I'm 
> flexible, the only thing I want is a noticable indent and tab; I don't
> really care if it's anywhere between one and four, but eight is too many.
> Actually the only comment I remember making is that I always preferred
> blocks like this:
> 
>     if( ) {
>     // do something
>     }
> 
> which I guess isn't very popular.  I did, however, utilize the xemacs
> indent thing that Tom Lane posted here a couple weeks ago.  Thanks Tom!

OK, now we have two items on the floor.  One is 8 vs. 4 space tabs, and
the other is different bracketing as illustrated above.

I have only Vince on the new bracketing.  Let's see if others vote for
new bracketing too.

I have Tom Lane, Jan, and Peter voting for 8-space tabs, and myself and
Andreas voting for 4-space tabs.  I think we all agree on 4-space
indenting.

Any more votes?  I see there is more discussion on this in my mailbox.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: AW: [HACKERS] LONG varsize - how to go on (pgindent)

From
Bruce Momjian
Date:
> OK, now we have two items on the floor.  One is 8 vs. 4 space tabs, and
> the other is different bracketing as illustrated above.
> 
> I have only Vince on the new bracketing.  Let's see if others vote for
> new bracketing too.
> 
> I have Tom Lane, Jan, and Peter voting for 8-space tabs, and myself and
> Andreas voting for 4-space tabs.  I think we all agree on 4-space
> indenting.
> 
> Any more votes?  I see there is more discussion on this in my mailbox.

While we are waiting for votes, I have added the needed sections to the
developers FAQ on the web site and on the main tree.  This certain
should have been done earlier.

If we don't get enough votes to change the tab size to 8, maybe we can
add the /* Local variables */ line to the bottom of all the C files.  
That would make Emacs users happy.  Of course, that only does Emacs.
We could throw .exrc files in the directories for vi users, usually as
one file and symlinks to the main file.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: AW: [HACKERS] LONG varsize - how to go on (pgindent)

From
Hannu Krosing
Date:
Tom Lane wrote:
> 
> Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at> writes:
> > I think the idea at that time was also, that with a tab only setup
> > people can look at the code with 2 space, 3 space and 4 space indents,
> > whatever suits them best.
> 
> Not really.  If the code still looked OK at different tab widths, people
> wouldn't be complaining.  A fairly typical example is
> 
>     if (root->query_pathkeys == NIL ||
>         pathkeys_contained_in(root->query_pathkeys,
>                               final_rel->cheapestpath->pathkeys))
>     {
>         root->query_pathkeys = final_rel->cheapestpath->pathkeys;
> 
> which is really
> 
> <tb>if (root->query_pathkeys == NIL ||
> <tb><tb>pathkeys_contained_in(root->query_pathkeys,
> <tb><tb><tb><tb><tb><tb><tb>  final_rel->cheapestpath->pathkeys))
> <tb>{
> <tb><tb>root->query_pathkeys = final_rel->cheapestpath->pathkeys;

So we either need ident that understands C syntax and formats the 
above as 

<tb>if (root->query_pathkeys == NIL ||
<tb><tb>pathkeys_contained_in(root->query_pathkeys,
<tb><tb>                      final_rel->cheapestpath->pathkeys))
<tb>{
<tb><tb>root->query_pathkeys = final_rel->cheapestpath->pathkeys;

or just use spaces for indentation

I transferred all my coding to spaces-only after starting with python 
about 5-6 years ago, as in python the whitespace is meaningful to parser 
too and not only to human reader.
Python has even a special script for detecting space/tab combinations 
that can potentially break things.

And it would be easy for someone who desparately needs tabs in his code
to run a much-simpler-than-indent script on the spaces only source to get 
what we have currently (and another script to put the spaces back before 
submitting patches)

-------------------
Hannu


Re: AW: [HACKERS] LONG varsize - how to go on (pgindent)

From
Bruce Momjian
Date:
> OK, now we have two items on the floor.  One is 8 vs. 4 space tabs, and
> the other is different bracketing as illustrated above.
> 
> I have only Vince on the new bracketing.  Let's see if others vote for
> new bracketing too.
> 
> I have Tom Lane, Jan, and Peter voting for 8-space tabs, and myself and
> Andreas voting for 4-space tabs.  I think we all agree on 4-space
> indenting.
> 
> Any more votes?  I see there is more discussion on this in my mailbox.

OK, I have 3 for 8-space tabs, 2 for 4-space tabs, and 1 for no tabs.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026