Re: format for declaring variables?
- From: Daniel Rudy <spamthis@xxxxxxxxxxxx>
- Date: Fri, 09 Feb 2007 02:22:00 -0800
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
.
- Follow-Ups:
- Re: format for declaring variables?
- From: CBFalconer
- Re: format for declaring variables?
- From: Richard Heathfield
- Re: format for declaring variables?
- From: Chris Dollin
- Re: format for declaring variables?
- References:
- format for declaring variables?
- From: Daniel Rudy
- Re: format for declaring variables?
- From: Daniel Rudy
- Re: format for declaring variables?
- From: Richard Heathfield
- format for declaring variables?
- Prev by Date: Re: format for declaring variables?
- Next by Date: Re: IS this a proper way of freeing memory with free()
- Previous by thread: Re: format for declaring variables?
- Next by thread: Re: format for declaring variables?
- Index(es):
Relevant Pages
|
Loading