Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rochester.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!rochester!ken From: ken@rochester.UUCP (Ken Yap) Newsgroups: net.lang.c Subject: Re: the one and only objection to C Message-ID: <5090@rochester.UUCP> Date: Thu, 3-Jan-85 05:03:41 EST Article-I.D.: rocheste.5090 Posted: Thu Jan 3 05:03:41 1985 Date-Received: Fri, 4-Jan-85 00:47:21 EST References: <1265@orca.UUCP> <86@mit-athena.ARPA> <4841@utzoo.UUCP> <545@vu44.UUCP> <5062@rochester.UUCP> <640@bunker.UUCP> Reply-To: ken@rochester.UUCP (Ken Yap) Organization: U. of Rochester, CS Dept. Lines: 41 Summary: It seems that my respondents picked on parts of my posting that they did not agree with. I was trying to point out something more interesting. Let me try again. * As currently defined, or by the weight of existing programs, structs have ordered fields but may have holes in them. This seems to me both lax and restrictive. Lax because alignment is not specified and makes device registers descriptions (for example) compiler-dependent. Restrictive because a lot of programs do not care if the fields are not allocated in the same order as they were declared. * I do not seriously believe in putting an offset declaration feature in C now. The syntax will probably be ugly and it is too radical a change. * The points I was trying to make are these: (1) By removing the ordering requirement, the compiler has more room to optimize. (Another optimization: compilers could put the more frequently used fields nearer the front and use shorter offsets in machine code.) Tell me if I am wrong, but Pascal can already do this because the language does not guarantee field ordering in records. (2) By giving the programmer a facility to control ordering/alignment for those times when he cares, the code tells the compiler that alignment must be preserved even at the expense of speed. The answer for people who want to read binary files, write ANSI headers, describe devices, do obscene things with data structures, et cetera. * Surely this is the best of both worlds and worth considering in any new language design? That is what I wanted to say. I know this is a contentious newsgroup and I sometimes don't say what I mean very well (I am tempted to rewrite the above). How about some comments if you think it worth your while commenting on, instead of making net.lang.c a religious battlefield. I really should have added a :-) after the "flame away" in my last posting. -- Ken Yap UUCP: (..!{allegra, decvax, seismo}!rochester!ken) ARPA: ken@rochester.arpa USnail: Dept. of Comp. Sci., U. of Rochester, NY 14627. Voice: Ken!