public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: coding style, continuing education
@ 2001-01-19  6:14 McNulty Junior Bobby
  0 siblings, 0 replies; 21+ messages in thread
From: McNulty Junior Bobby @ 2001-01-19  6:14 UTC (permalink / raw)
  To: Joerg Faschingbauer, dewar; +Cc: gcc

Hey, quit talking about my coding style. :)
If you ever seen seen son of mine before i had a
friend clean it up, then you'd see why I quit coding.



--- Joerg Faschingbauer <jfasch@aon.at> wrote:
> From: dewar@gnat.com
> Subject: Re: coding style, continuing education
> Date: Mon, 15 Jan 2001 19:44:25 -0500 (EST)
> 
> > <<Caution -- sequence points, lazy evaluation,
> side effects. It's not just
> > boolean algebra.
> > 
> > Tom
> > >>
> > 
> > If this makes a difference, you are talking about
> seriously horrible code :-)
> 
> Bah! What about this one :-?
> 
>    /* :-))) */
>    (
>       // the basic things.
>       (e += typespec_.matchExact (p.type())).error()
> || 
>       (e += namespec_.match (p.name())).error() ||
> 
>       // either both enums are set or none.
>       (enumspec_.isSet() && !p.eNum().isSet() ||
> !enumspec_.isSet() && p.eNum().isSet()) && 
>       (e += HW_Reason(classid,E_MATCH), 1) ||
> 
>       // either both ranges are set or none.
>       (rangespec_.isSet() && !p.range().isSet() ||
> !rangespec_.isSet() && p.range().isSet()) && 
>       (e += HW_Reason(classid,E_MATCH), 1) ||
>       
>       // enum and range (if given) must match
> exactly.
>       enumspec_.isSet() && (e += enumspec_.match
> (p.eNum())).error() ||
>       rangespec_.isSet() && (e += rangespec_.match
> (p.range())).error() ||
>       
>       // either .. or ...
>       (defaultspec_.isSet() && !p.def().isSet() ||
> !defaultspec_.isSet() && p.def().isSet()) &&
>       (e += HW_Reason(classid,E_MATCH), 1) ||
> 
>       (defaultspec_.isSet() && 
>        ((((e += defaultspec_.value().equal(b,
> p.def().value())).error()) || !b) && 
>           (e += HW_Reason(classid,E_MATCH), 1)))
>       ) ;
> 
> Joerg


=====
Robert McNulty Junior
Robert McNulty Junior (C) 2000
email: bmcnultyjunior@yahoo.com
Homepage: http://www.geocities.com/bmcnultyjunior
AIM:bmcnultyjrsap
Featuring Csound compiled with a Win32/Intel Based Compiler

^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: coding style, continuing education
@ 2001-01-19  2:45 Richard Kenner
  2001-01-19  4:37 ` Tom Leete
  2001-01-19  4:46 ` Phil Edwards
  0 siblings, 2 replies; 21+ messages in thread
From: Richard Kenner @ 2001-01-19  2:45 UTC (permalink / raw)
  To: nix; +Cc: gcc

    with a thoroughly misleading comment above it (is that what the entire
    conditional does? no, it's what the first clause does), 

That raises an interesting issue: where *does* the comment for what the first
clause does go?  I've been putting it before the entire statement, but,
as you point out, that's not ideal.  Should we be doing something like:

	/* This tells when we need to ....  */

	if (
	    /* We need to if ... */
	    <conditional expression>
	    /* ... or if ... */
            <next conditional expression>

^ permalink raw reply	[flat|nested] 21+ messages in thread
* RE: coding style, continuing education
@ 2001-01-17  9:52 David Korn
  0 siblings, 0 replies; 21+ messages in thread
From: David Korn @ 2001-01-17  9:52 UTC (permalink / raw)
  To: gcc

>-----Original Message-----
>From: Michael Matz [ mailto:matzmich@cs.tu-berlin.de ]
>Sent: 17 January 2001 17:40

>On Mon, 15 Jan 2001, Mike Stump wrote:
>> 
>> If people _know_ of a good way to split this down, maybe we all just
>> need a refresher course on the right way, care to elaborate?
>> 
>> [ long expression snipped ]
>
>Even more entertaining is reload.c:push_reload. It has two expressions (in
>if's), 62 and 50 lines long, intersparsed with #ifdef's, so it not even
>fits on one editor page. They have comments in front of them, but it isn't
>exactly easy to at least verify, if these expressions actually do, what
>the comments explain ;-)

  You know what would come in handy here?  Some kind of automated tool for
processing these messes.  I imagine it would have to read in and parse a
bit of C code, building a syntax tree as it went.  It could even simplify
the expression somewhat by spotting duplicated subexpressions and 
eliminating them, or by applying mathematical transformations and boolean
algebra.  Obviously it would have to know all about C types and evaulation
rules, but hopefully it could then output the transformed code in some
simpler format.

  Oh.  Hold on a minute.  We already have one of those...

         DaveK
-- 
The Boulder Pledge: "Under no circumstances will I ever purchase anything 
offered to me as the result of an unsolicited email message. Nor will I 
forward chain letters, petitions, mass mailings, or virus warnings to large 
numbers of others. This is my contribution to the survival of the online
community."


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

^ permalink raw reply	[flat|nested] 21+ messages in thread
* RE: coding style, continuing education
@ 2001-01-16 13:20 Bruce Korb
  0 siblings, 0 replies; 21+ messages in thread
From: Bruce Korb @ 2001-01-16 13:20 UTC (permalink / raw)
  To: 'dewar@gnat.com', Bruce Korb, patrick; +Cc: gcc, mrs

I would add one more KISS rule:

Never ever regard any other rules as absolute :-)

True.  I forgot that one  ;-)

^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: coding style, continuing education
@ 2001-01-16 12:42 dewar
  0 siblings, 0 replies; 21+ messages in thread
From: dewar @ 2001-01-16 12:42 UTC (permalink / raw)
  To: bkorb, patrick; +Cc: gcc, mrs

I would add one more KISS rule:

Never ever regard any other rules as absolute :-)

Seriously, none of those 6 rules are absolute rules, and there can
be good reasons for breaking any of them!

^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: coding style, continuing education
@ 2001-01-15 16:44 dewar
  2001-01-18 13:53 ` Joerg Faschingbauer
  0 siblings, 1 reply; 21+ messages in thread
From: dewar @ 2001-01-15 16:44 UTC (permalink / raw)
  To: bkorb, tleete; +Cc: gcc, mrs

<<Caution -- sequence points, lazy evaluation, side effects. It's not just
boolean algebra.

Tom
>>

If this makes a difference, you are talking about seriously horrible code :-)

^ permalink raw reply	[flat|nested] 21+ messages in thread
* coding style, continuing education
@ 2001-01-15 14:03 Mike Stump
  2001-01-15 14:37 ` Zack Weinberg
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Mike Stump @ 2001-01-15 14:03 UTC (permalink / raw)
  To: gcc

I know that historically gcc has had thousand line functions, and
worse, but as time goes on we clean up the various sorts of code and
make it prettier.  It is just like the line formatting rules, see a
line longer than 80, and one should just split on demand, not stopping
to think twice about if they should do it or not.  I'm tracking down a
problem on an older compiler, and was traipsing around the code below.
Icky.  I think it would help if people realize that this code is like
the > 80 character lines, one should just take a moment and split it
down.  I think we should all just agree that conditionals that run on
past 20 or so lines should be split.  Maybe we need a new gcc warning
when the opening ( and the closing ) are more than 20 lines apart, we
warn.  We could also have a { } checker that will warn when they are
more than, say 2000 lines apart.  Someone want to work on a useful
warning that will hit often?  :-)

If people _know_ of a good way to split this down, maybe we all just
need a refresher course on the right way, care to elaborate?


	if (mode1 == VOIDmode
	    || GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG
	    || (modifier != EXPAND_CONST_ADDRESS
		&& modifier != EXPAND_INITIALIZER
		&& ((mode1 != BLKmode && ! direct_load[(int) mode1]
		     && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT
		     && GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT)
		    /* If the field isn't aligned enough to fetch as a memref,
		       fetch it as a bit field.  */
		    || (mode1 != BLKmode
			&& SLOW_UNALIGNED_ACCESS (mode1, alignment)
			&& ((TYPE_ALIGN (TREE_TYPE (tem))
			     < GET_MODE_ALIGNMENT (mode))
			    || (bitpos % GET_MODE_ALIGNMENT (mode) != 0)))
		    /* If the type and the field are a constant size and the
		       size of the type isn't the same size as the bitfield,
		       we must use bitfield operations.  */
		    || ((bitsize >= 0
			 && (TREE_CODE (TYPE_SIZE (TREE_TYPE (exp)))
			     == INTEGER_CST)
			 && 0 != compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)),
						   bitsize)))))
	    || (modifier != EXPAND_CONST_ADDRESS
		&& modifier != EXPAND_INITIALIZER
		&& mode == BLKmode
		&& SLOW_UNALIGNED_ACCESS (mode, alignment)
		&& (TYPE_ALIGN (type) > alignment
		    || bitpos % TYPE_ALIGN (type) != 0)))
	  {

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2001-01-22 13:05 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-19  6:14 coding style, continuing education McNulty Junior Bobby
  -- strict thread matches above, loose matches on Subject: below --
2001-01-19  2:45 Richard Kenner
2001-01-19  4:37 ` Tom Leete
2001-01-19  4:46 ` Phil Edwards
2001-01-19 15:30   ` Nix
2001-01-22 13:05     ` Bruce Korb
2001-01-17  9:52 David Korn
2001-01-16 13:20 Bruce Korb
2001-01-16 12:42 dewar
2001-01-15 16:44 dewar
2001-01-18 13:53 ` Joerg Faschingbauer
2001-01-15 14:03 Mike Stump
2001-01-15 14:37 ` Zack Weinberg
2001-01-15 14:53 ` Bruce Korb
2001-01-15 16:42   ` Tom Leete
2001-01-15 17:46     ` Bruce Korb
2001-01-16  0:14 ` sidster
2001-01-16 10:10   ` Bruce Korb
2001-01-16 22:12 ` Bill Wendling
2001-01-17  9:42 ` Michael Matz
2001-01-18 23:27   ` Nix

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).