hardcoded constants

RAMontante bobmon at iuvax.cs.indiana.edu
Sat Dec 17 00:47:42 AEST 1988


henry at utzoo.uucp (Henry Spencer) writes:
-
-Trouble is, often it's almost impossible to devise a meaningful name.
-I'm not talking about hard-coding things like choice of control characters,
-but about things like (in a function to concatenate two strings with a
-'/' in between):
-
-	foo = malloc(strlen(a)+strlen(b)+2);	/* 2 for '/' '\0' */
-
-Now, what's a good name for that "2", and how does naming it improve
-readability?

#define STRING_TERMINATOR_LENGTH  2

is descriptive, but I think only a fanatic Pascalist could love it.  And
only somebody with a more-than-80-column display would want to use it.

more-fun-with-Henry's-signatures follows:

--
-"God willing, we will return." -Eugene Cernan, the Moon, 1972

I like it, but it's not obvious whether God understands "we" to mean
"Americans".  Neil Armstrong had to go and get ecumenical with his
"...giant leap for mankind".  And now it's those godless communists who
have a space station...



More information about the Comp.lang.c mailing list