From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20155 invoked from network); 11 May 2020 17:32:50 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 11 May 2020 17:32:50 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 4A1609C5E7; Tue, 12 May 2020 03:32:49 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 5230F9C2ED; Tue, 12 May 2020 03:32:19 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 8A65A9C2ED; Tue, 12 May 2020 03:32:16 +1000 (AEST) Received: from central.weird.com (unknown [198.96.117.51]) by minnie.tuhs.org (Postfix) with ESMTP id D81959B75D for ; Tue, 12 May 2020 03:32:15 +1000 (AEST) Received: from (invalid client hostname: bind: DNS error: DNS lookup for A for 'more.local': Unknown host)more.local ((no PTR matching greeting name)S01060026bb6c284e.ok.shawcable.net[24.71.254.93] port=48584) by central.weird.com([198.96.117.51] port=587) via TCP with esmtp (4829 bytes) (sender: ) (ident using UNIX) id for ; Mon, 11 May 2020 13:32:14 -0400 (EDT) (Smail-3.2.0.122-Pre 2005-Nov-17 #78 built 2020-Mar-25) Received: from (invalid client hostname: the DNS A record (with the targegt address [10.0.1.129]) for the hostname 'more.local' does not match the expected address [10.0.1.129])more.local ((no PTR matching greeting name)future.local[10.0.1.133] port=50058) by more.local([10.0.1.129] port=25) via TCP with esmtp (4319 bytes) (sender: ) id for ; Mon, 11 May 2020 10:32:14 -0700 (PDT) (Smail-3.2.0.122-Pre 2005-Nov-17 #1 built 2015-Feb-17) Message-Id: Date: Mon, 11 May 2020 10:32:14 -0700 From: "Greg A. Woods" To: The Unix Heritage Society mailing list In-Reply-To: <20200511005745.GL17035@mcvoy.com> References: <6D6EFA0C-36C3-4225-A331-D1998A07C50A@gmail.com> <3cb1126796176debe28aa66672ba27ae@yaccman.com> <20200511005745.GL17035@mcvoy.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.3 (x86_64--netbsd) MULE/6.0 (HANACHIRUSATO) X-Face: ; j3Eth2XV8h1Yfu*uL{<:dQ$#E[DB0gemGZJ"J#4fH*][ lz; @-iwMv_u\6uIEKR0KY"=MzoQH#CrqBN`nG_5B@rrM8,f~Gr&h5a\= List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The Unix Heritage Society mailing list Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --pgp-sign-Multipart_Mon_May_11_10:31:56_2020-1 Content-Type: text/plain; charset=US-ASCII At Sun, 10 May 2020 17:57:46 -0700, Larry McVoy wrote: Subject: Re: [TUHS] v7 K&R C > > > On Mon, May 11, 2020 at 10:28 AM wrote: > > > With respect to enums, there is a feature I've wanted for years: a typed > > > typedef. Saying typetdef int foo would make foo an integer, but if you > > > passed an ordinary int to something declared as foo it would be an error. > > > Even if it was an integer constant unless cast. > > Steve, I couldn't agree more, you are 100% right, this is how it should > work. I wanted to like enums because I naively thought they'd have these > semantics but then learned they really aren't any different than a well > managed list of #defines. Absolutely agreed! The lameness of typedef (and in how enum is related to typedef) is one of the saddest parts of C. (The other is the default promotion to int.) It would be trivial to fix too -- for a "new" C, that is. Making it backward compatible for legacy code would be tough, even with tooling to help fix the worst issues. I've seen far too much code that would be hard to fix by hand, e.g. some that even goes so far as to assume things like arithmetic on enum values will produce other valid enum values. Ideally enums could be a value in any native type, including float/double. > IMHO, without your semantics, enums are pretty useless, #define is good > enough and more clear. Actually that's no longer true with a good modern toolchain, especially with respect to the debugger. A good debugger can now show the enum symbol for a (matching) value of a properly typedefed variable. (In fact I never thouth that a #define macro was more clear, even before debugger support -- the debugger support just gave me a better excuse to use to explain my preference!) -- Greg A. Woods Kelowna, BC +1 250 762-7675 RoboHack Planix, Inc. Avoncote Farms --pgp-sign-Multipart_Mon_May_11_10:31:56_2020-1 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit Content-Description: OpenPGP Digital Signature -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQTWEnAIIlcZX4oAawJie18UwlnHhQUCXrmMFAAKCRBie18UwlnH hZWkAKDGhe63RvJqW7rWDOHkN8TkFHGVXwCeIIGCcClF03BIV/5CdtcSdKDfLDM= =Jftr -----END PGP SIGNATURE----- --pgp-sign-Multipart_Mon_May_11_10:31:56_2020-1--