Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!pt!ius2.cs.cmu.edu!edw From: edw@ius2.cs.cmu.edu (Eddie Wyatt) Newsgroups: comp.lang.c Subject: Re: enum - enum ? Message-ID: <1208@ius2.cs.cmu.edu> Date: Fri, 19-Jun-87 11:42:23 EDT Article-I.D.: ius2.1208 Posted: Fri Jun 19 11:42:23 1987 Date-Received: Tue, 23-Jun-87 01:11:11 EDT References: <7906@brl-adm.ARPA> Organization: Carnegie-Mellon University, CS/RI Lines: 74 In article <7906@brl-adm.ARPA>, jfjr@mitre-bedford.arpa writes: > > One of the things I like about Pascal (Yes I *definitely* do like > Pascal) is its handling of enumerated scalar types (and subranges thereof) > I could find true happiness and fulfilment if C would handle > enums the same way - right now the approach seems to be muddled > and schizophrenic. Imagine, with the power C has to be able to > increase its readiblity (which it hasn't) by allowing TRUE array > indexing with enums( 'twould be paradise enow) > > Jerry Freedman,Jr > jfjr@mitre-bedford.arpa You've touched two bad notes with me here: One calling Pascal a usable language and, two saying C code in general is not readable. Lets talk about Pascal. Let me see you write a single function to do a sumation over an array of of integers of arbitrary size. Can't do it huh. The problem, Pascal doesn't suppose "generic" array sizes. Case statements in Pascal are a total failure. Since there is no default clause, one has to test whether the switch variable is in the case statement's range or is outside the range. You might as well use if-then-elses. There are loop holes in Pascals suppositely "can't screw yourself over" attitude too. One in the function as a parameter to function construct, there's no way of specifying the arguements to the input function. Hence one could do something like declare a function that takes 2 arguements. Pass that function to another function as an arguement and call the input function with 3 arguements when it was declared to take only two. The other loop hole that I can think of is the use of case variant records to access data that is in one form say int as another say float. Another flop is the conditional expressions. Pascal does not do short-circuit evaluation of conditional expressions. This posses at least two problems, the obvious one being less efficient code. The other being the awkward constructs that one must use to achieve the equivalent of short-circuit evaluation. The old if (not (p = nil)) then if (p^.field = x) then ..... You call that more readable then this! if (p && p->field == x) ... And how about "despose". Dynamic memory allocation is in the Pascal definition. I would like to see one implementation of "despose" that did something reasonably. Clearing the heap up until the pointer that you are freeing is not reasonable! Other little things to squawk about o no bit-wise operations o no separate compulation o no utilities like most C implementations (refering to stdio.h, varargs.h ....) Now for the issue of readability in C. This really is more of an issue of the PROGRAMMER'S ABLITY to write readable code, not the languages syntax or semantics! At least in the case of C vs Pascal. -- Eddie Wyatt e-mail: edw@ius2.cs.cmu.edu terrorist, cryptography, DES, drugs, cipher, secret, decode, NSA, CIA, NRO.