Naming conventions
T. William Wells
bill at twwells.com
Tue Jun 20 21:00:51 AEST 1989
In article <1297 at garcon.cso.uiuc.edu> mcdaniel at uicsrd.csrd.uiuc.edu (Tim McDaniel) writes:
: Usually, I would not have "g_" prefixes on the members. Instead, I
: name *pointer and structure variables* according to their types. I
: would declare a pointer as
: struct glumph_t * glumph_p;
: (thereby confusing the hell out of any LISP programmer who stumbles
: upon my code, but he deserves it) or even as
: struct glumph_t * glumph;
:
: You see, I *really* *like* descriptive names. If they're long, c'est
: la vie. If a variable represents a descriptor (in places where
: there's no confusion about what kind of thing it's descripting),
: I bloody well call it "descriptor"! Or at least prefix it with
: "desc_".
The scheme you use is only appropriate for *generic* pointers of a
given type. In other words, if I have a pointer used for a general
temp, I'm likely to call it struct passwd passwd_ptr. But if I use the
pointer to refer to a particular structure, I use something like
struct passwd users_password_entry. And in that case, the field name
prefix helps clue me in as to the specific structure.
No, I don't think that struct passwd users_password_entry_passwd_ptr
is a good idea; the thing defeats the purpose by being unreadable.
---
Bill { uunet | novavax | ankh | sunvice } !twwells!bill
bill at twwells.com
More information about the Comp.lang.c
mailing list