Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!labrea!rocky!rokicki From: rokicki@rocky.STANFORD.EDU (Tomas Rokicki) Newsgroups: comp.sys.amiga Subject: Re: Manx C Message-ID: <476@rocky.STANFORD.EDU> Date: Sat, 8-Aug-87 02:13:01 EDT Article-I.D.: rocky.476 Posted: Sat Aug 8 02:13:01 1987 Date-Received: Sun, 9-Aug-87 12:55:19 EDT References: <4540@jade.BERKELEY.EDU> <1836@vax135.UUCP> Reply-To: rokicki@rocky.UUCP (Tomas Rokicki) Distribution: comp Organization: Stanford University Computer Science Department Lines: 38 Keywords: look at the assembly. > I'm not trying to contribute to this back-and-forth which is starting > up, but I personally question the need for using the 'int' type under > Manx. There are plenty of reasons to use int. First, int is defined as the most `natural' size of a word. For most values, this gives you speed. For instance, if you use a 16-bit value when the int size is 32, in each expression, that value will be expanded to a 32-bit value. Those additional instructions add up. A 32-bit value where a 16-bit value is more appropriate takes longer to fetch. The less you mix word lengths in expressions, usually, the more efficient your code is. Secondly, scanf and printf use %d for ints, and %ld for longs. Here you *must* use ints, or do your own formatting, or do some fancy #ifdef'ing to select the appropriate string (if your code is to be portable.) I use the stdio library regularly; it's portable, fairly efficient, and pretty powerful. Thirdly, all arguments to functions are coerced to at least ints if they are smaller. This is another case where using an int can avoid some type coercions. Now, typedefs have there place, certainly, and for arrays and the like, they are invaluable. But judicious use of int's can help your C compiler do a good job. For instance, the VAX 4.3bsd C compiler won't put a short in a register. The same compiler, and hcc on an IBM RT, have a rather serious bug when comparing an unsigned short to an int. And, then, of course, you have the standard functions, which typically expect int's. Here, at least, passing a short is safe, since it will be expanded to an int on compilers which use 32-bit ints, but passing a long will break on 16-bit C compilers. I never use the +L option in Manx. It's worth the additional speed. And it's not that hard to write code that is portable to 16-bit int machines and 32-bit int machines. -tom