Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!ncar!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: arrays... Message-ID: <11325@mimsy.UUCP> Date: 3 May 88 04:14:42 GMT References: <5773@sigi.Colorado.EDU> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 41 Summary: not enough kinds of unnamed aggregates In article <5773@sigi.Colorado.EDU> swarbric@tramp.Colorado.EDU (Frank Swarbrick) writes: -Is there some reason why you can do: - -void foo(const int *bar); -main() { - int ary[] = {1,2,3,4}; - foo(ary); -} (Pre-dpANS compilers will not even do this; `ary' must be `static' or global. The restriction on automatic aggregate initialisers has been lifted in dpANS C.) -but you can't do - -void foo(const int *bar); -main() { - foo({1,2,3,4}); -} Yes: there is no aggregate builder that builds an array of int. -... This is even stranger concidering you *can* do - -main() { - char str[20]; - strcpy(str,"This sucks!"); -} - strcpy(str,{'T','h','i','s',' ','s','u','c','k','s','\0'}); -doesn't work.... ... but there *is* an aggregate builder that builds an array of char, namely "". Some of us feel that this is a flaw in the language, that the only way to get most kinds of aggregates is to provide names for them. (Of course, if you add unnamed aggregates, you should also add unnamed functions.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris