Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!ihnp4!ho95e!wcs From: wcs@ho95e.ATT.COM (Bill.Stewart) Newsgroups: comp.lang.c Subject: Re: A bad design decision early on in ANSI C. Message-ID: <1942@ho95e.ATT.COM> Date: 1 Jan 88 01:22:14 GMT References: <1322@sugar.UUCP> Reply-To: wcs@ho95e.UUCP (46323-Bill.Stewart,2G218,x0705,) Organization: AT&T Bell Labs 46133, Holmdel, NJ Lines: 34 In article <1322@sugar.UUCP> peter@sugar.UUCP (Peter da Silva) writes: >I would like to suggest removing a "feature" from 'C'. >Structure assignment/passing. Structure assignment/passing is part of the 1980 (1979?) extensions to the C language, which also included enum and void. While they're newer than K&R, and some early PC C compilers don't include them, they're an established part of the language, and infinite numbers of programs would brreak if they went away. The dp ANSI standard is correct in keeping them. Peter gives three objections to them: 1) If you mess up a function call (add/delete &) you've got a real mess. True, but this is what "lint" is good for. Actually, it's safer to mess up one of these than a more normal variable, because the results are so ugly you'll *probably* notice them. 2) Sometimes your stack overflows if you use them. Only if the program was too big for the machine anyway. While the ability to pass structures encourages people to put more on a stack than necessary, it's easy to see what they've done and modify it if your machine is too small. Does your machine have a big data space but a 64K stack size, or are mallocs just as unsafe? 3) They don't really add anything. But they do - they add data hiding. A library can provide types such as time_t and addr_t for data that is generated by some library routines and used by others, and *you* don't have to know what the type is. If the variable won't fit in a scalar on your machine (either because it's too big, or because you've got a segmented architecture or perverse operating system), and you've disallowed structure assignment, *you* may have to know what the structure looks like inside. -- # Thanks; # Bill Stewart, AT&T Bell Labs 2G218, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs