From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: C++ diaries... Date: Fri, 07 Jun 2019 11:22:42 -0700 Organization: None to speak of Message-ID: References: <60027108-2b92-417e-8083-eef19cc1e64a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="0d5b010e2076a714ee1f32c348b9a975"; logging-data="12759"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BIYUbElIROh7lUQyjllOv" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:MR/Txt5XvUH26VaIMoj3kRnz2gg= sha1:ohFjrym2i0T/6eaPsmC/yiOM6FQ= Xref: reader01.eternal-september.org comp.lang.ada:56543 Date: 2019-06-07T11:22:42-07:00 List-Id: Olivier Henley writes: [...] > I already said so, all of the above. The thing, 'straight enums', > should have worked properly day one. The concept of enum in C++ is > arguably deceitful, wrong, broken, you name it. [...] The concept of enum in C++ is not what you wanted it to be. C's enum types are derived directly from C's. In C, which does not support overloading of identifiers, enumeration constants are of type int. For example: enum color { red, green, blue }; defined "enum color" as a discrete type, and "blue" as a constant equivalent to a literal 2. C++ tightens this up slightly by making the constants be of the enum type (mostly, I think, to allow the constants to be used with overloaded functions), but they're still freely assignable to and from integer types. More recently, C++ added a new "enum class" feature which is closer to what you want enums to be -- but the older form goes back to the 1980s, and there are uncounted lines of code depending on it. Making C enums strongly typed from the beginning would have caused problems *in the environment in which the language was defined and used*. Changing them in an incompatible way would have broken existing code. Ada was designed with a different philosophy. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */