First of all, thanks to Thomas Bushnell, BSG for taking the time to
answer my newbie questions.
> (like, say, Scheme), and you should learn to get used to it and even
> use it in your own programs!  It makes things much cleaner overall.
Well, I guess even old dogs can learn new tricks, the idea of local
procedures isn't completely alien, I learned Pascal before C, and Turbo
Pascal for CPM-2.2 was my first compiler - I got the MSDOS version as
well, to run on my Zenith Z-100, and it did have local procedures. But
some of us are so used to seeing a compilation unit start off with
staitic variables and functions, that we never think of doing it the
'proper' way...
> 
> That would only slow the code down and do nothing in increase
> clarity.
I see it in a different perspective now, and it makes sens. I guess I
have stared too much at the NCB, which is as close I have ever come to
something resembling the Hurd structure ... programming client/server
applications for NetBIOS.
I hope that some of the ideas from that can come in handy here, though.
I used an 8-bit 8088 PC as server, which is better than single-step :-)
> 
> ports_manage_port_operations_multithread is called once in most
> servers; some have two separate service operations going on and call
> it twice.
That changes everything. I guess the first thing I will have to do is
find a program that reads the source tree and draws up the dependencies
- if that is not already done. 
> 
> do stmt while (condition) {};
> 
> is illegal syntax, since this is a do/while loop.  In while loops with
> empty bodies, I always put the semi on a separate line for just this
> reason.
I have read RMS' paper on coding style, and I really like it. I diagree
with the idea that programming is 'art' - art should be appreciated by
other people than the artists themselves. To me, programming is a craft,
like making houses or furniture. Just as architecture can be beautiful,
the logic of a program and its architecture has esthaethic value, but
that is not enough to qualify it as art. So, 'style' is really
'standard'. That said, I will follow it, with the exception of
bracketing (is this a Nordic thing?), where I tend to agree with Kalle:

        while ( ! fatlady_sings) {
                stmts;
        }

        do {
                show();
        } while ( ! singing(fatlady));

Especially in the latter case, I see an advantage: No need for /* end
while */, because it can not be confused with a while loop.

For functions, I grew up with K & R C, I remember when the first
ANSI-compiler came, that would bring 'strong typing' to C. I was so
excited that I adopted it right away, and I had to write ansi2kr to
translate. I adopted my own style:

/*
* controlstructnew (structs.h) - Create a new controlstruct and describe
what this is for,
* and talk a lot about it, so that it can be used for the manpages.
* I haven't yet thought about this in detail, but I guess som XML stuff
or meta-comments should be here as well
*/
struct control *controlstruct_new(
        packe_t x25,    /* (packe_t.h) Always good to know where stuff is defined
*/
        indeb_t *ed,    /* (indebt.h) Some editors open the h-file when clikking
on a ref to it */
        killstruc_t william) /* (solutions.h) Open the Gates */
{
        This that; /* I think it is useful to know what the variables are for
:-) */
        et_c    etc; /* Even when it is obvious (Nothing is obvious) */
}

This retains the best of both worlds. I see a conflict between the use
of GCC extensions and sticking to K&R syntax - the inverse would make
more sense: Stick to ANSI syntax but use no extensions. Luckily, the
wold spins clockwise, and GCC is becoming a de facto standard - so local
procedures may not be an extension at all in the near future.

It will be a great comfort to you all that I will write down everything
I discover and learn, and I don't expect to learn this fast, so it will
tak a long time before you see any of my code ...

Greetings , Atle


Reply via email to