more about programming style

Chris Torek chris at umcp-cs.UUCP
Fri Aug 9 22:11:06 AEST 1985


(Perhaps I should just let this one slide by, but I'm feeling
particularly ornery this morning :-) ....)

>So you can understand:
>    int (*foo[10])();
>That doesn't help someone who is reading your program who doesn't.
>But writing the declaration as done below does.
>   typedef int (*PFI)();          /* pointer to function returning int */
>   PFI foo[10];

Much better than either of those is, instead, doing the following:

	/*
	 * Each input character in the range '0'..'9' invokes the
	 * corresponding translation function from the table below.
	 * The translation function returns the new state.
	 */
	int (*trans_function[10])() = {
		...

(or	PFI trans_function[10] = { ... ).

Describe the *purpose* of the data structures!
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.lang.c mailing list