Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!brl-smoke!smoke!cottrell@NBS-VMS.ARPA From: cottrell@NBS-VMS.ARPA (COTTRELL, JAMES) Newsgroups: net.lang.c Subject: Enums as Indices Message-ID: <1081@brl-smoke.ARPA> Date: Tue, 18-Feb-86 19:12:18 EST Article-I.D.: brl-smok.1081 Posted: Tue Feb 18 19:12:18 1986 Date-Received: Wed, 19-Feb-86 20:41:31 EST Sender: news@brl-smoke.ARPA Lines: 25 /* > ---though to my mind using enumerated types as indicies is `treading > on thin ice' (I have no explanation as to why I feel this way; I > just do). > -- > In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) Perhaps I can allay some of your doubts. First, remember that in AWK subscripts may be string valued. Thus: `/apple/ { x["apple"]++ }' is OK. Second, I feel that ENUM's are merely a way of writing #defines with a bit of type checking thrown in (thus the error). One of the things you can do with integers is use them for subscripts. I can imagine a statement like `wavelenth[RED] = however_many_angstroms_red_really_is'. This moves us closer to a database view of things where the sparse matrix of things like 'RED', 'BLUE', etc., are mapped into small integers. An expression such as `wavelength['RED'] = ...' is currently legal altho not recommended (portability). I am reminded of LISP's property lists, which are conceptually `indices of arbitrary type.' Another thought that comes to mind is that struxure members are somewhat enumerated offset constants for a particular struxure. Remember how they used to do struxures in FORTRASH? Oh, well, I'm rambling. jim cottrell@nbs */ ------