Date: Fri, 8 Jul 2022 09:40:47 -0400
On Fri, Jul 8, 2022 at 5:57 AM Oktlryk via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Hello
>
> I was doing a course over at Udemy on Unreal Engine C++ programming, and tons of the code (I mean there were a lotta functions involving this) enabled or disabled some boolean or set some value to true/false, as like in semaphore types.
>
> And I had to write two functions for each like: void EnableStuff() + void DisableStuff(). Which got me thinking, why not handle this at the language level. Like you could indicate if a function was a Enable/Disable actuator and only require the expressed inclusion of the function in definition. For example:
>
> void endis Stuff(bool setMe); // endis (Enable/Disable keyword)
>
> then when calling:
>
> Stuff.enable() = enable // sets setMe to true
> Stuff.disable() = disable // sets setMe to false
>
> And C++ automatically generates the enable/disable switches, not requiring further function defs and so on!! This will definitely be a super cool improvement to the C++ QOL.
This is way too narrowly focused to bother with. "Enable" and
"Disable" functions are not nearly common enough (or difficult enough
to write) to add a *language* feature for. You can easily make a
function that takes a bool (or preferably an enum) and call that
directly.
<std-proposals_at_[hidden]> wrote:
>
> Hello
>
> I was doing a course over at Udemy on Unreal Engine C++ programming, and tons of the code (I mean there were a lotta functions involving this) enabled or disabled some boolean or set some value to true/false, as like in semaphore types.
>
> And I had to write two functions for each like: void EnableStuff() + void DisableStuff(). Which got me thinking, why not handle this at the language level. Like you could indicate if a function was a Enable/Disable actuator and only require the expressed inclusion of the function in definition. For example:
>
> void endis Stuff(bool setMe); // endis (Enable/Disable keyword)
>
> then when calling:
>
> Stuff.enable() = enable // sets setMe to true
> Stuff.disable() = disable // sets setMe to false
>
> And C++ automatically generates the enable/disable switches, not requiring further function defs and so on!! This will definitely be a super cool improvement to the C++ QOL.
This is way too narrowly focused to bother with. "Enable" and
"Disable" functions are not nearly common enough (or difficult enough
to write) to add a *language* feature for. You can easily make a
function that takes a bool (or preferably an enum) and call that
directly.
Received on 2022-07-08 13:43:12