Re: ACMD(do_quit)

From: Justin (justinl@mac.com)
Date: 01/17/02


> ACMD(do_quit)
> It's probably staring me right in the face, in bold, bright, blinking
> letters. But for some odd reason I still don't see it...

I would just like to make a few comments about the coding conventions in the
code shown, and not about what the code is doing. Hopefully, along with
other posters' comments, they'll help you find your own mistakes.

First, I see a switch with only one case. If statements are, in general,
better to use than switches - especially when there's only one case
(although a modern compiler would probably compile them both the same,
anyway). I agree that for a few cases or more, switches are easier to read.

Second, you're using two separate conventions for bracketing around lines
you wish to include in an if statement. My personal habit is to do as you
did in your: if (*arg == 'n' || *arg == 'N') {. Here you bracketed, and
dropped it on the next line. This is good, because a simple glance will tell
you exactly what the if statement encompasses. There are some above (namely
the two in the case) that could confuse you later (or now!) by not knowing
what you intended to include.

If I KNOW that I'm not going to need more than one line for an if statment,
and I really want to save space, I move it up, like:

if (*arg == 'n' || *arg == 'N') STATE(d) = CON_PLAYING;

That way, I again know what the if statement controls.

It doesn't matter which convention you pick - because it's yours, but you
should pick one. It'll help save your hair ;).

Justin

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT