tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: UVM typedef struct



At Fri, 19 Jun 2009 17:18:26 +0000, David Holland 
<dholland-tech%netbsd.org@localhost> wrote:
Subject: Re: UVM typedef struct
> 
> Historically, *_t types are primitive types

No, not really, especially not in C generally (perhaps in Unix, but
there are perhaps other explanations for why Unix code failed to use
this powerful idiom as uniformly as it should have).


> Historically also structures are always used as "struct foo"; but
> preserving this convention is not as important as not treading on
> other related conventions.

Well, maybe, if you go back in time so far that "typedef" didn't exist.

Of course if you go back that far you'll find even header include files
were poorly used (in Unix code, that is) and full "struct" definitions
where copied willy nilly to whichever sources they were used in.


> So, if we want to do this, which I don't have a strong opinion about,
> can we use some naming convention other than _t?

I really strongly disagree with the idea of not using "_t" for typedef
names.

Historically the real reason for appending "_t" to typedef names is to
mark the identifier as being a "type" -- i.e. it's a special identifier
that exists in a unique namespace.

This is useful for _all_ types of syntax highlighting, including that
done implicitly by the human eye and brain.

In your example "vm_page" is by default a variable name to me, not a
type name.

The use of the "_t" suffix on typedef names is an incredibly important
idiom that should be used everywhere possible.


FWIW, I do also disagree with including the "*" pointer qualifier in the
typedef unless the name somehow reflects this fact, such as fooptr_t,
foop_t, foo_p_t, or foo_pt, or something like that (so long as it's
consistent, especially with existing code, from anywhere, if indeed
there's anything already statistically consistent, which would in my
experience be the "fooptr_t" form).

-- 
                                                Greg A. Woods
                                                Planix, Inc.

<woods%planix.com@localhost>       +1 416 218-0099        http://www.planix.com/

Attachment: pgprYbGF7FrOB.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index