C++ Logo

std-proposals

Advanced search

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

From: Henry Miller <hank_at_[hidden]>
Date: Sun, 14 Aug 2022 18:39:12 -0500
A language feature is only better if this is a common operation, otherwise it is syntax to ban in my code style document. This is not something i've ever needed which makes me suspect it is a rare situation. Prove that this is a common operation on some well written code and I'll reconsider.

Note that I specified well written there are a lot of frameworks that require weird things that we now agree are wrong. If you point to one of them we will respond switch to a better framework.


-- 
  Henry Miller
 hank_at_[hidden]
On Sun, Aug 14, 2022, at 16:17, Greg McPherran via Std-Proposals wrote:
> 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
> -- 
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2022-08-14 23:39:36