comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst-u@mib.org>
Subject: Re: C++ diaries...
Date: Fri, 07 Jun 2019 11:22:42 -0700
Date: 2019-06-07T11:22:42-07:00	[thread overview]
Message-ID: <lna7ets1al.fsf@kst-u.example.com> (raw)
In-Reply-To: bc15333c-03b2-485c-be81-2c444abace1c@googlegroups.com

Olivier Henley <olivier.henley@gmail.com> 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  <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

  reply	other threads:[~2019-06-07 18:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06 16:32 C++ diaries Olivier Henley
2019-06-06 16:54 ` Olivier Henley
2019-06-07  7:32   ` Maciej Sobczak
2019-06-07 17:55     ` Olivier Henley
2019-06-07 18:22       ` Keith Thompson [this message]
2019-06-07 23:04         ` Olivier Henley
2019-06-07 23:09         ` Keith Thompson
2019-06-07 18:29       ` Lucretia
2019-06-07 23:27         ` Olivier Henley
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox