Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!pacbell!att-ih!cuuxb!ltuxa!ll1a!spl1!laidbak!daveb From: daveb@laidbak.UUCP (Dave Burton) Newsgroups: comp.lang.c Subject: Re: { initializer-list , } Message-ID: <1378@laidbak.UUCP> Date: 14 Mar 88 21:04:25 GMT References: <660@kuling.UUCP> Reply-To: daveb@laidbak.UUCP (Dave Burton) Organization: is pretty bad/My method of Lines: 29 In article <660@kuling.UUCP> bjornc@kuling.UUCP (Bj|rn Carlsson) writes: >Why is an optional trailing comma inside the braces after an initializer-list >allowed? Since it doesn't affect the meaning of the initializer we can't >see any other reasons for including it except historical. Is it included >in the Draft proposed ANSI C? We are currently writing a compiler for a >subset of C and got a bit confused when finding this strange syntax. >It is documented in both K&R and Harbison&Steele (2nd ed.). I (ab)use this syntax all the time when writing programs with a large number of initializers. It is very useful when this list must undergo maintenance - additions, deletions, reorganization, etc. For example: static char *message[] = { "message", "another message", "yam", "...", "etc", }; If more messages need to be added, just tack 'em on. It also has the potential to make automatic program generators (a trivial amount) easier to implement. -- --------------------"Well, it looked good when I wrote it"--------------------- Verbal: Dave Burton Net: ...!ihnp4!laidbak!daveb V-MAIL: (312) 505-9100 x325 USSnail: 1901 N. Naper Blvd. #include Naperville, IL 60540