Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think!mintaka!ogicse!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: Nested Comments in C -- A recent experience Message-ID: <12351@goofy.megatest.UUCP> Date: 16 Mar 90 22:58:05 GMT References: <2381@dataio.Data-IO.COM> Organization: Megatest Corporation, San Jose, Ca Lines: 85 From article <2381@dataio.Data-IO.COM>, by bright@Data-IO.COM (Walter Bright): > In article <9130008@hpavla.AVO.HP.COM> gary@hpavla.AVO.HP.COM (Gary Jackoway) writes: > << (void) memcpy(/*targ*/ (void *) &x, /*src*/ (void *) &y, sizeof(y)); > < (void) memcpy((void *) &x, (void *) &y, sizeof(y)); > < (void) memcpy((void *) &x, (void *) &y, sizeof(y)); > > It's more readable if you eliminate the redundant clutter: > memcpy(&x,&y,sizeof(y)); /* Copy y into x */ Strictly speaking, you have to keep the (void*) casts, just in case some enemy system codes some kinds of pointers in screwy ways. It can happen. So we got this: memcpy((void*)&x,(void*)&y,sizeof(y)); /* Copy y into x */ Not too bad. If I had my way, the C++ style out-to-the-end-of-the-line comment would be the only kind available. // Know what I mean, Bean? But then, if I had my way, I wouldn't be programming now would I? I would have WAY to much money to bother with work. As it is, I use only two styles: /* * Block comments * that can go on and on... */ ... and ... /* ... out to end of line comments. */ The reason I don't do blocks ... /* ... like a bunch */ /* of out to end */ /* of line comments... */ ... is that blocks like that are too hard to edit, especially if you like to ... /* ... line up the */ /* comment-ends */ /* nice and tidy. */ Rarely, I do want to put comments on actual parameters, as in the original memcpy example. I still use the o-t-e-o-l comment: memcpy( (void*)&y, /* target */ (void*)&x, /* source */ sizeof(y) ); I guess KR indentation purists would do this: memcpy( (void*)&y, /* target */ (void*)&x, /* source */ sizeof(y) ); Nah, maybe not. One of the most affected comment styles that I have seen inflicted on the innocent code-reading public had all the comments on the left! Made me just want to take the guy and shake him. /* It all looked */ main(argv, argc) /* really weird, */ char** argv; /* even pompous, */ { /* you know what */ printf("Goodbye, cruel world.\n"); /* I mean, Bean? */ }