Another silly question

James D. Allen jamesa at arabian.Sun.COM
Mon May 22 07:45:39 AEST 1989


In article <10299 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>In article <13234 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:
>>... outlawing "i[a]" would have been a small step
>>towards making arrays higher-class citizens than they are.
>
>I don't think you can ever make the existing C arrays first-class
>objects without invalidating large amounts of existing correct code.
>There are efforts underway to find a suitable language extension
>that solves this problem (for the new class of objects provided by
>the extension).

One source of trouble is "hidden" array typedefs, such as `jmp_buf'.
(You have to "know" what a jmp_buf is to use it nontrivially, while
if it were "first-class" you wouldn't.)  But a logical array can be
promoted to a first-class citizen by just putting it in a structure:

		typedef struct {
			jmp_buf j;
		} first_class_jmpbuf;

Any idea why this wasn't done for jmp_buf's?

I think the "second-classedness" of arrays helps give C its elegant
syntax.  Any other examples of the "problems" it causes?



More information about the Comp.lang.c mailing list