Re: [Patches] [Patch #102813] _cursesmodule: Add panel support

On Fri, Dec 22, 2000 at 07:07:03AM -0800, noreply@sourceforge.net wrote:
* Guido-style: 8-column hard-tab indents. * New style: 4-column space-only indents.
Hm, I must have missed this... Is 'new style' the preferred style, as its name suggests, or is Guido mounting a rebellion to adhere to the One True Style (or rather his own version of it, which just has the * in pointer type declarations wrong ? :) -- Thomas Wouters <thomas@xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

Thomas Wouters writes:
Guido has grudgingly granted that new code in the "New style" is acceptable, mostly because many people complain that "Guido style" causes too much code to get scrunched up on the right margin. The "New style" is more like the recommendations for Python code as well, so it's easier for Python programmers to read (Tabs are hard to read clearly! ;). -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Fred L. Drake, Jr. writes:
I am reminded of Linus Torvalds comments on this subject (see /usr/src/linux/Documentation/CodingStyle): Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

Charles G Waldman writes:
I am reminded of Linus Torvalds comments on this subject (see /usr/src/linux/Documentation/CodingStyle):
The catch, of course, is Python/cevel.c, where breaking it up can hurt performance. People scream when you do things like that.... -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Fred L. Drake, Jr. writes:
The catch, of course, is Python/cevel.c, where breaking it up can hurt performance. People scream when you do things like that....
Quoting again from the same source: Use helper functions with descriptive names (you can ask the compiler to in-line them if you think it's performance-critical, and it will probably do a better job of it that you would have done). But I should have pointed out that I was quoting the great Linus mostly for entertainment/cultural value, and was not really trying to add fuel to the fire. In other words, a message that I thought was amusing, but probably shouldn't have sent ;-)

Charles G Waldman writes:
I understood the intent; I think he's really got a point. There are a few places in Python where it would really help to break things up! -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Fred wrote:
I understood the intent; I think he's really got a point. There are a few places in Python where it would really help to break things up!
if that's what you want, maybe you could start by putting the INLINE stuff back again? <halfwink> (if C/C++ compatibility is a problem, put it inside a cplusplus ifdef, and mark it as "for internal use only. don't use inline on public interfaces") </F>

Fredrik Lundh writes:
if that's what you want, maybe you could start by putting the INLINE stuff back again? <halfwink>
I could not see the value in the inline stuff that configure was setting up, and still don't.
We should be able to come up with something reasonable, but I don't have time right now, and my head isn't currently wrapped around C compilers. -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Fred wrote:
the INLINE stuff guarantees that "inline" is defined to be whatever directive the compiler uses for explicit inlining. quoting the autoconf docs: If the C compiler supports the keyword inline, do nothing. Otherwise define inline to __inline__ or __inline if it accepts one of those, otherwise define inline to be empty as a result, you can always use "inline" in your code, and have it do the right thing on all compilers that support ex- plicit inlining (all modern C compilers, in practice). ::: to deal with people compiling Python with a C compiler, but linking it with a C++ compiler, the config.h.in file could be written as: /* Define "inline" to be whatever the C compiler calls it. To avoid problems when mixing C and C++, make sure to only use "inline" for internal interfaces. */ #ifndef __cplusplus #undef inline #endif </F>

Fred replied:
The catch, of course, is Python/cevel.c, where breaking it up can hurt performance. People scream when you do things like that....
Funny, Jeremy is doing just that, and it doesn't seem to be hurting performance at all. See http://sourceforge.net/patch/?func=detailpatch&patch_id=102337&group_id=5470 (though this is not quite finished). --Guido van Rossum (home page: http://www.python.org/~guido/)

[Thomas Wouters]
Every time this comes up wrt C code, 1. Fred repeats that he thinks Guido caved in (but doesn't supply a reference to anything saying so). 2. Guido repeats that he prefers old-style (but in a wishy-washy way that leaves it uncertain (*)). 3. Fredrik and/or I repeat a request for a BDFL Pronouncement. 4. And there the thread ends. It's *very* hard to find this history in the Python-Dev archives because these threads always have subject lines like this one originally had ("RE: [Python-Dev] Re: [Patches] [Patch #102813] _cursesmodule: Add panel support"). Fred already did the #1 bit in this thread. You can consider this msg the repeat of #3. Since Guido is out of town, we can skip #2 and go straight to #4 early <wink>. (*) Two examples of #2 from this year: Subject: Re: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/ Modules mmapmodule.c,2.1,2.2 From: Guido van Rossum <guido@python.org> Date: Fri, 31 Mar 2000 07:10:45 -0500
Actually, this one was formatted for 8-space indents but using 4-space tabs, so in my editor it looked like 16-space indents! Given that we don't want to change existing code, I'd prefer to stick with 1-tab 8-space indents. Subject: Re: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Modules linuxaudiodev.c,2.2,2.3 From: Guido van Rossum <guido@beopen.com> Date: Sat, 08 Jul 2000 09:39:51 -0500
Yes, you're right.

2. Guido repeats that he prefers old-style (but in a wishy-washy way that leaves it uncertain (*)).
OK, since a pronouncement is obviously needed, here goes: Python C source code should be indented using tabs only. Exceptions: (1) If 3rd party code is already written using a different style, it can stay that way, especially if it's a large volume that would be hard to reformat. But only if it is consistent within a file or set of files (e.g. a 3rd party patch will have to conform to the prevailing style in the patched file). (2) Occasionally (e.g. in ceval.c) there is code that's very deeply nested. I will allow 4-space indents for the innermost nesting levels here. Other C whitespace nits: - Always place spaces around assignment operators, comparisons, &&, ||. - No space between function name and left parenthesis. - Always a space between a keyword ('if', 'for' etc.) and left paren. - No space inside parentheses, brackets etc. - No space before a comma or semicolon. - Always a space after a comma (and semicolon, if not at end of line). - Use ``return x;'' instead of ``return(x)''. --Guido van Rossum (home page: http://www.python.org/~guido/)

Thomas Wouters writes:
Guido has grudgingly granted that new code in the "New style" is acceptable, mostly because many people complain that "Guido style" causes too much code to get scrunched up on the right margin. The "New style" is more like the recommendations for Python code as well, so it's easier for Python programmers to read (Tabs are hard to read clearly! ;). -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Fred L. Drake, Jr. writes:
I am reminded of Linus Torvalds comments on this subject (see /usr/src/linux/Documentation/CodingStyle): Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

Charles G Waldman writes:
I am reminded of Linus Torvalds comments on this subject (see /usr/src/linux/Documentation/CodingStyle):
The catch, of course, is Python/cevel.c, where breaking it up can hurt performance. People scream when you do things like that.... -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Fred L. Drake, Jr. writes:
The catch, of course, is Python/cevel.c, where breaking it up can hurt performance. People scream when you do things like that....
Quoting again from the same source: Use helper functions with descriptive names (you can ask the compiler to in-line them if you think it's performance-critical, and it will probably do a better job of it that you would have done). But I should have pointed out that I was quoting the great Linus mostly for entertainment/cultural value, and was not really trying to add fuel to the fire. In other words, a message that I thought was amusing, but probably shouldn't have sent ;-)

Charles G Waldman writes:
I understood the intent; I think he's really got a point. There are a few places in Python where it would really help to break things up! -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Fred wrote:
I understood the intent; I think he's really got a point. There are a few places in Python where it would really help to break things up!
if that's what you want, maybe you could start by putting the INLINE stuff back again? <halfwink> (if C/C++ compatibility is a problem, put it inside a cplusplus ifdef, and mark it as "for internal use only. don't use inline on public interfaces") </F>

Fredrik Lundh writes:
if that's what you want, maybe you could start by putting the INLINE stuff back again? <halfwink>
I could not see the value in the inline stuff that configure was setting up, and still don't.
We should be able to come up with something reasonable, but I don't have time right now, and my head isn't currently wrapped around C compilers. -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Fred wrote:
the INLINE stuff guarantees that "inline" is defined to be whatever directive the compiler uses for explicit inlining. quoting the autoconf docs: If the C compiler supports the keyword inline, do nothing. Otherwise define inline to __inline__ or __inline if it accepts one of those, otherwise define inline to be empty as a result, you can always use "inline" in your code, and have it do the right thing on all compilers that support ex- plicit inlining (all modern C compilers, in practice). ::: to deal with people compiling Python with a C compiler, but linking it with a C++ compiler, the config.h.in file could be written as: /* Define "inline" to be whatever the C compiler calls it. To avoid problems when mixing C and C++, make sure to only use "inline" for internal interfaces. */ #ifndef __cplusplus #undef inline #endif </F>

Fred replied:
The catch, of course, is Python/cevel.c, where breaking it up can hurt performance. People scream when you do things like that....
Funny, Jeremy is doing just that, and it doesn't seem to be hurting performance at all. See http://sourceforge.net/patch/?func=detailpatch&patch_id=102337&group_id=5470 (though this is not quite finished). --Guido van Rossum (home page: http://www.python.org/~guido/)

[Thomas Wouters]
Every time this comes up wrt C code, 1. Fred repeats that he thinks Guido caved in (but doesn't supply a reference to anything saying so). 2. Guido repeats that he prefers old-style (but in a wishy-washy way that leaves it uncertain (*)). 3. Fredrik and/or I repeat a request for a BDFL Pronouncement. 4. And there the thread ends. It's *very* hard to find this history in the Python-Dev archives because these threads always have subject lines like this one originally had ("RE: [Python-Dev] Re: [Patches] [Patch #102813] _cursesmodule: Add panel support"). Fred already did the #1 bit in this thread. You can consider this msg the repeat of #3. Since Guido is out of town, we can skip #2 and go straight to #4 early <wink>. (*) Two examples of #2 from this year: Subject: Re: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/ Modules mmapmodule.c,2.1,2.2 From: Guido van Rossum <guido@python.org> Date: Fri, 31 Mar 2000 07:10:45 -0500
Actually, this one was formatted for 8-space indents but using 4-space tabs, so in my editor it looked like 16-space indents! Given that we don't want to change existing code, I'd prefer to stick with 1-tab 8-space indents. Subject: Re: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Modules linuxaudiodev.c,2.2,2.3 From: Guido van Rossum <guido@beopen.com> Date: Sat, 08 Jul 2000 09:39:51 -0500
Yes, you're right.

2. Guido repeats that he prefers old-style (but in a wishy-washy way that leaves it uncertain (*)).
OK, since a pronouncement is obviously needed, here goes: Python C source code should be indented using tabs only. Exceptions: (1) If 3rd party code is already written using a different style, it can stay that way, especially if it's a large volume that would be hard to reformat. But only if it is consistent within a file or set of files (e.g. a 3rd party patch will have to conform to the prevailing style in the patched file). (2) Occasionally (e.g. in ceval.c) there is code that's very deeply nested. I will allow 4-space indents for the innermost nesting levels here. Other C whitespace nits: - Always place spaces around assignment operators, comparisons, &&, ||. - No space between function name and left parenthesis. - Always a space between a keyword ('if', 'for' etc.) and left paren. - No space inside parentheses, brackets etc. - No space before a comma or semicolon. - Always a space after a comma (and semicolon, if not at end of line). - Use ``return x;'' instead of ``return(x)''. --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (6)
-
Charles G Waldman
-
Fred L. Drake, Jr.
-
Fredrik Lundh
-
Guido van Rossum
-
Thomas Wouters
-
Tim Peters