[net.lang.c] Initializing Vars in non-OS C sy

ucbesvax.turner@ucbcad.UUCP (07/24/83)

#R:ihnss:-161800:ucbesvax:4800018:000:1561
ucbesvax!turner    Jul 24 00:21:00 1983

The question: is there any difference in initializing in the
declaration (of auto vars, I assume) as opposed to using statements.

(I tried personal mail, but it bounced back, so here is my response.
If the last question about initializations is any indication, there will
be 3.5 zillion responses; I have added a suggestion along different
lines, so that it won't be totally redundant.)

In all implementations I've seen, initializing in the declarations
makes no difference.  Which style is *clearer* is a matter of taste.
Personally, I initialize at the point of declaration whenever possible,
since the problem with a typed language is saying anything meaningful
on one screen.  (More properly a problem with screen-sizes--I happen
to like strongly-typed languages.)

By the way, since you are working on a machine with few registers, you
should know about the following optimization:

	foo()
	{
		register a,b;

		{
		register c;
		...
		}
		{
		register d;
		...
		}
	}

This style will involve allocating at most 3 registers to the user,
whereas

	foo()
	{
		register a,b,c,d;
		...
	}

will take 4 if 4 are available--in your case, probably not.  By
partitioning your code carefully, you can speed it up somewhat.
In the case of the 8086, you need all the help you can get.

	Michael Turner
	ucbvax!ucbesvax.turner

P.S.  The only 8086 C compiler I have used is Computer Innovations
      C86, which, if I recall correctly, ignores all but the first
      "register" declaration.  Pretty dismal.  Anyone know of anything
      better, in this respect?