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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26531 invoked from network); 11 May 2020 18:25:44 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 11 May 2020 18:25:44 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 950399C5E0; Tue, 12 May 2020 04:25:42 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id BAA299C2ED; Tue, 12 May 2020 04:25:21 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vgL9WgWs"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 082BD9C2ED; Tue, 12 May 2020 04:25:19 +1000 (AEST) Received: from mail-vs1-f53.google.com (mail-vs1-f53.google.com [209.85.217.53]) by minnie.tuhs.org (Postfix) with ESMTPS id 5B9489B75D for ; Tue, 12 May 2020 04:25:18 +1000 (AEST) Received: by mail-vs1-f53.google.com with SMTP id h30so6219640vsr.5 for ; Mon, 11 May 2020 11:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=IfhNOot5nK49rcfLVV2QWOHM9fgYk6nTp8LkyXzxwqQ=; b=vgL9WgWs2qjIC6mKBir9cHR16Z0HkvFKM54U+mJ2OdQ78gO1Vgbm0uRH5h7Z9+cIGx jqKjN2B9OpyxB5bYw4pRWsTuDTh6a50wFWFA+voQMMBO10DoawqyIomYqaDQdhXYF/i5 47qHg7w8x0i52zyDL8MV9TLPqtn79hGLk4PY+32086Brhi3XgKMOnKhpN28e5PL91jqP nl2hDdGLe4Jk9ze2IUbNaLE8U4Ok+oCVJDn/pdfJX3vaiwhypq02zoQTiOuk39snwwM6 R84pByQm43QzFq+VT5dnOltvGMZ+G7GLNmRbtCKybqc1IQ3g1kUxxWG7NFhR0o++Mez4 5ttg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=IfhNOot5nK49rcfLVV2QWOHM9fgYk6nTp8LkyXzxwqQ=; b=pYjC9CO41egpnDYxlknsJRGllr4fbZ6d464RysGVhg118St1wbYOCWWewy0Vj9CUpk HhYkVoW6l1pCHQufwoXI1+um+Yfpohc5JG4gYYO4o9Q03xXhOChAam3/9JZPrkt4mu5P SNwrNbSY3wTxQX6/KkNIk9HQGdSashV5mgBKDEIQ4BjvKqvKeZZrJepdk5cofXQE+U4w 7HaLQGalnc/aXZbOsoAg8np/24icTw5YzcJa1pCnZ1NQ5ifVHX+fJhqsCetVNclLDPdj EQjOFi054pQZFGMbxTRIJAPqqVpoFNKIFLo+T/hYgr0P0nVkwa3tQq8f7FF7H4ZB5GEH e4KA== X-Gm-Message-State: AGi0PuZWHsOplAUS67lE7Q+fmcLbA8oWLttwfw0waDkWlUa2GyEKR0Wk NMhiWy45gRWZyEyDnPy2AV9SQQXYj87xo6sgqlxRwQ== X-Google-Smtp-Source: APiQypJ1sTvUMGnacpBPueFOxGkXvLZLvCQ0R3fhuBQ27DjI53tCkOPYZKyLxAwbzxyyrLPkVyi97JYrV1/gzjW4r+0= X-Received: by 2002:a05:6102:3c7:: with SMTP id n7mr11947904vsq.179.1589221517093; Mon, 11 May 2020 11:25:17 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:4717:0:0:0:0:0 with HTTP; Mon, 11 May 2020 11:25:15 -0700 (PDT) In-Reply-To: References: <6D6EFA0C-36C3-4225-A331-D1998A07C50A@gmail.com> <3cb1126796176debe28aa66672ba27ae@yaccman.com> <20200511005745.GL17035@mcvoy.com> From: Paul Winalski Date: Mon, 11 May 2020 14:25:15 -0400 Message-ID: To: The Unix Heritage Society mailing list Content-Type: text/plain; charset="UTF-8" Subject: Re: [TUHS] v7 K&R C X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" On 5/11/20, Greg A. Woods wrote: > > 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.) I would add a third: file-scope declarations being global by default. One must use the keyword "static" to restrict a file-scope declaration to the file it's declared in. And why "static"? All file-scope declarations have static allocation. Why isn't the keyword "local" or "own"? Anyway, the way it ought to be is that file-scope declarations are restricted to the file they're declared in. To make the symbol visible outside its file, you should have to explicitly say "global". > 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. This ought to be easy to fix using a compiler command line option for the legacy behavior. Many C compilers do this already to support K&R semantics vs. standard C semantics. > Ideally enums could be a value in any native type, including float/double. Except pointers, of course. >> 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. Indeed. -Paul W.