Re: format for declaring variables?



At about the time of 2/9/2007 2:03 AM, Richard Heathfield stated the
following:
Daniel Rudy said:

<snip>

Anyways, I know that this IS platform specific,

Fortunately, that doesn't matter here (and anyway, you tried, right?).


Tried? Not sure what you mean there...

but here's what I saw, copied verbatim from the source file:

int
kenv(td, uap)
struct thread *td;
struct kenv_args /* [...] */ *uap;
{

That's legal.

Ok. That form threw me for a loop. I had no idea what was going on.

The modern form is:
int
kenv(struct thread *td, struct kenv_args *uap)
{

They have identical semantics for all intents and purposes, except that
the latter form allows stricter type-checking by the compiler.


I've only used the modern form. People using different styles like that
makes the code much harder to read and decipher. But for a project as
complicated as an operating system kernel (that's what that code
fragment is from), you have a bunch of different people working on
different parts and everybody has their own style.


OT: Speaking of style, forms like this bug me:

if ((fc = open(filename)) < 0)
errx("file error %d\n", errno);

How hard is it to sit there and do this instead?

fc = open(filename);
if (fc < 0) errx("file error %d\n", errno);

It's just so much easier to read, less error prone (since there are
fewer nested () ), and it probably generates the exact same code at the
machine level.


--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
.



Relevant Pages

  • Re: Kerlock/Harlock
    ... > transfer his essence into the mainframe computer of Harlock's ship the ... Some characters die over and over again, ... Decode email address using b64decode or uudecode -m ... strip view finger mount fcsk more fcsk yes spray umount sleep ...
    (rec.arts.anime.misc)
  • Re: Sanyo DS31580 Dead - Blown Fuse
    ... fuse and now it turns on, I hear the whine of the flyback, and then it ... I did fix my Sony ... Decode email address using b64decode or uudecode -m ... strip view finger mount fcsk more fcsk yes spray umount sleep ...
    (sci.electronics.repair)
  • Re: CRT Tube Socket
    ... Decode email address using b64decode or uudecode -m ... look chat date touch grep make unzip ... strip view finger mount fcsk more fcsk yes spray umount sleep ...
    (sci.electronics.repair)
  • Re: CRT Tube Socket
    ... large areas of the picture to black out. ... Decode email address using b64decode or uudecode -m ... Why geeks like computers: look chat date touch grep make unzip ... strip view finger mount fcsk more fcsk yes spray umount sleep ...
    (sci.electronics.repair)
  • Re: Sanyo DS31580 Dead - Blown Fuse
    ... Horizontal Output Transistor - open ... I borrowed a flyback ringer from a friend and ringed out the flyback, ... Decode email address using b64decode or uudecode -m ... strip view finger mount fcsk more fcsk yes spray umount sleep ...
    (sci.electronics.repair)

Loading