From: Olivier Henley <olivier.henley@gmail.com>
Subject: Re: C++ diaries...
Date: Fri, 7 Jun 2019 16:04:48 -0700 (PDT)
Date: 2019-06-07T16:04:48-07:00 [thread overview]
Message-ID: <aaf35355-1908-453b-b164-e6d20fc879b6@googlegroups.com> (raw)
In-Reply-To: <lna7ets1al.fsf@kst-u.example.com>
On Friday, June 7, 2019 at 2:22:44 PM UTC-4, Keith Thompson wrote:
> 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.
I know all this.
These facts do not absolve an absurd design and all the man hours it cost for decades.
Life is short sir. I say we should struggle for better ways than accepting 'absurdly clashing identifiers' ... as a status quo of design.
next prev parent reply other threads:[~2019-06-07 23:04 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
2019-06-07 23:04 ` Olivier Henley [this message]
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