Just Wondering

Tom Stockfisch tps at chem.ucsd.edu
Mon Apr 24 17:33:50 AEST 1989


In article <1126 at ptolemy.arc.nasa.gov> raymond at ptolemy.UUCP (Eric A. Raymond) writes:
>In article <10088 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>>>    Why is C case-sensitive?
>>It makes programs considerably more readable, and expands the available
>>name space considerably.

>I agree that they improve your namespace, but not in any usable way.
>(Sort of like the big gear/little gear combinations on a bike.  You
>can use them, but it's not a good idea.)  Although its debatable, I
>feel its bad style to use the same name (in diffrent cases) for
>different purposes within a program.

I try to avoid it, but I succumbed to temptation after reading C++ code.
In C++ a struct tag name is also used as the name of a constructor for
that struct.  In C I always use upper case for types and (mostly) lower
case for functions.  I used to use lower case for types until I ran into
a pcc bug in which inner-scope auto variable names collide with typedef
names.  Anyway, I now use the lower case version of a struct name as the
name of the constructor of the struct.  e.g.,

	typedef struct NODE {
		char		*name;
		struct	NODE	*lchild;
		struct	NODE	*rchild;
	}	NODE;

	NODE *
	node(name)
		char	*name;
	{
		NODE	*result =	malloc( sizeof(NODE) );

		result->name =		strsave(name);
		result->lchild =
		result->rchild =	NULL;
		return	result;
	}

Note that I overload NODE as the structure tag and typedef name.  This
also is similar to the way C++ does things.
-- 

|| Tom Stockfisch, UCSD Chemistry	tps at chem.ucsd.edu



More information about the Comp.lang.c mailing list