C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Class Instance Re-Use/Re-Init

From: Greg McPherran <GMcPherran_at_[hidden]>
Date: Sun, 14 Aug 2022 21:17:26 +0000
Hi,

Great workaround suggestions by some, but the existence of these
workarounds proves my point that a language feature is superior. One can
also accomplish OO-like behavior in C without C++, but the syntax of C++
is superior. Before C++ existed and a C programmer suggested classes and
objects as a feature, once could argue "you don't need that, you can use
function pointers in structs". Yes, "workarounds" exist but the whole
point of language syntax is to incorporate it into the more simple and
concise patterns of the language usage.

By the way, along with this feature, I also request a related feature
for "const after init once". This related feature would be very helpful
for objects that are conceptually intended to be global constants but
one would like the chance the initialize them once (and only once) at
runtime (typically in early startup time). So they are automatically
const after they are initialized the first time.

So, in summary, the two features that I am requesting as a C++ customer
are:
Ctor-like re-init once-and-done special functions that are not available
as normal functions after init just as ctor is not available as a normal
function on an object.
const after first init
Thank You,
Greg McPherran

Received on 2022-08-14 21:17:28