Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!decwrl!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Another silly question Message-ID: <13415@haddock.ima.isc.com> Date: 26 May 89 03:40:21 GMT References: <17812@cup.portal.com> <607@kl-cs.UUCP> <749@mccc.UUCP> <13269@haddock.ima.isc.com> <96@elf115.uu.net> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 34 In article <96@elf115.uu.net> rec@elf115.uu.net (Roger Critchlow) writes: >In <13269@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes: >>In article <105998@sun.Eng.Sun.COM> jamesa@arabian.Sun.COM (James D. Allen) writes: >>>Any idea why this [enclosing in a struct] wasn't done for jmp_buf's? >> >>Originally? Probably shortsightedness. > >I believe that struct's were still second class objects when >jmp_buf was first declared. But arrays were (and still are) third-class objects. A struct would still have been the better choice. (Or do you mean to suggest that structs didn't exist at all? I bet if you go back that far, typedef didn't exist either.) >The declaration of a jmp_buf as an array means that the jmp_buf >is passed by reference instead of by value. This is essential >to many implementations of setjmp(). Of course it has to be passed by reference; the function needs to write in it, after all. But what *should* have been done was to typedef jmp_buf as a struct, and use "&" explicitly. That's what the rest of the library uses when call by reference is required. >I think of C arrays as syntactic sugar for initialized pointers. Thus > char foo[] = "I am an anonymous char *"; >is an abbreviation for > register char *const foo = "I am an anonymous char *"; This is very wrong, but I'll let Chris Torek explain why, since he already has it in his FAQ database. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint