Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Request for Comments: Aggregate Assignment in C ... Message-ID: <4479@goanna.cs.rmit.oz.au> Date: 11 Dec 90 06:43:46 GMT References: <77546@iuvax.cs.indiana.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 26 In article <77546@iuvax.cs.indiana.edu>, mayer@iuvax.cs.indiana.edu (Mayer Goldberg) writes: > We submit that a better way of doing this would be to allow a > kind of assignment that we allow during initialization. > Something like: > my_vec = {4,, 7}; If you want Ada, you know where to find it. It you want to make it easy for people to introduce subtle and difficult-to-locate mistakes in their programs, keep it up. A better approach is to write a function that fills in records struct ag mk_ag(int a, int b, int c) { struct ag ans; ans.a = a, ans.b = b, ans.c = c; return ans; } Then the struct declaration can have new fields added, or the fields re-ordered, and my_vec = mk_ag(4, 0, 7); will still work. (Hint: this is why Ada record constructors let you use keywords.) If your compiler supports inlining (gcc, for example) struct-building functions are good candidates for inlining. -- The Marxists have merely _interpreted_ Marxism in various ways; the point, however, is to _change_ it. -- R. Hochhuth.