Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!burl!codas!usfvax2!ateng!chip From: chip@ateng.UUCP Newsgroups: comp.lang.c Subject: Re: Structure constants Message-ID: <28@ateng.UUCP> Date: Fri, 2-Oct-87 13:42:22 EDT Article-I.D.: ateng.28 Posted: Fri Oct 2 13:42:22 1987 Date-Received: Sun, 4-Oct-87 02:36:38 EDT References: <843@usfvax2.UUCP> <8677@utzoo.UUCP> Reply-To: chip@ateng.UUCP (Chip Salzenberg) Organization: A.T. Engineering, Tampa, FL Lines: 57 In article <8677@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes: >> b = add_complex(a, (COMPLEX){1.0, 1.0} ); > >What is the type of the second argument if you omit the cast? If the cast >is mandatory, then all of a sudden it isn't a cast any more, it's a new >kind of animal that happens to resemble a cast. (Speaking as an implementor, >if it's going to make casts any more messy to parse, I don't want to hear >about it!) Good point. The first thing that comes to mind is this: b = add_complex(a, COMPLEX {1.0, 1.0}); which in fact could be generalized to allow b = add_array(a, int[] {1, 2, 3, 4, 5}) which could still share compiler code with initialization of auto aggregates, and which would finally fix the inconsistency of allowing only character arrays to be anonymous. ........... [If arrays as well as structures were allowed, then for sanity, I would disallow defaulting to type "int"; that is, foo(int *[] { &static1, &static2 }); would be legal, whereas foo(*[] { &static1, &static2 }); would be illegal. An initial "*" should simply mean "indirection through".] ............ Of course, this new syntax causes statements like print_complex(COMPLEX {1.0, 1.0}); to look to the compiler very much like a function prototype; by the time the '{' is encountered, a lot of ass_u_me'ing might have to be undone. Fortunately, the latest draft says that function declarations inside block scope are undefined, or so I've heard. If this is true, then there's no conflict -- outside block scope, assume prototype or function definition; inside block scope, assume function call. >Personally, I think it would be a useful thing, if you revised the syntax a >bit so the first part didn't look like a cast, but I am against adding it >to X3J11 in the absence of dire need. But I have a dire need to get something into the draft! :-) >"There's a lot more to do in space | Henry Spencer @ U of Toronto Zoology >than sending people to Mars." --Bova | {allegra,ihnp4,decvax,utai}!utzoo!henry -- Chip Salzenberg "{uunet,usfvax2}!ateng!chip" or "chip%ateng@uu.net" A.T. Engineering (If my employer agrees with my opinions, it's news to me.) "The word is `no.' I am therefore going anyway." -- Adm. James T. Kirk