Date: Thu, 10 Apr 2025 11:32:00 +0100
On Thu, 10 Apr 2025 at 11:07, Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Thu, Apr 10, 2025 at 10:40 AM Rhidian De Wit wrote:
> >
> > Hi Frederick,
> >
> > Isn't this a rather small problem to face? Granted an annoying one when
> it occurs,
> > but just not needing to add a single std::forward call in the one
> appropriate line
> > doesn't seem to be worth a language change
>
>
> I think it would reduce the possibility of introducing
> very-hard-to-find bugs. I mean let's say Billy The Programmer started
> out by writing the following function:
>
> template<typename T>
> void ProcessNode(T &&arg)
> {
> NormaliseNode(arg);
> DistributeNode(arg);
> AssimilateNode( forward<T>(arg) );
> }
>
> and the Mandy The Programmer came along a year later and added a new line:
>
> template<typename T>
> void ProcessNode(T &&arg)
> {
> NormaliseNode(arg);
> DistributeNode(arg);
> AssimilateNode( forward<T>(arg) );
> TrimMemoryUsage( forward<T>(arg) );
> }
>
> Of course this is a very very simple example, and Mandy would be able
> to see straight away that 'arg' was already forwarded on the previous
> line. But what if the function were 340 lines long, and what if Mandy
> missed that 'arg' had previously been forwarded. This bug could lead
> to the building of an executable binary that doesn't crash, but
> behaves oddly only for a few corner cases. The person tasked with
> fixing this bug might spend a long time trying to figure out what's
> gone wrong.
>
> The whole point of the trigraph reference is that it means that the
> programmer can no longer make the mistake.
>
I strongly recommend that you don't keep calling these digraphs and
trigraphs, those are pre-existing terms with a specific (and very
different) meaning.
Nobody says "digraph reference" when they mean forwarding reference or
universal reference or rvalue reference.
More generally, I agree that it's not worth introducing a whole new
language feature just to get the compiler to auto-forward in exactly one
place. It seems like a job for analyzers/linters or just compiler warnings.
std-proposals_at_[hidden]> wrote:
> On Thu, Apr 10, 2025 at 10:40 AM Rhidian De Wit wrote:
> >
> > Hi Frederick,
> >
> > Isn't this a rather small problem to face? Granted an annoying one when
> it occurs,
> > but just not needing to add a single std::forward call in the one
> appropriate line
> > doesn't seem to be worth a language change
>
>
> I think it would reduce the possibility of introducing
> very-hard-to-find bugs. I mean let's say Billy The Programmer started
> out by writing the following function:
>
> template<typename T>
> void ProcessNode(T &&arg)
> {
> NormaliseNode(arg);
> DistributeNode(arg);
> AssimilateNode( forward<T>(arg) );
> }
>
> and the Mandy The Programmer came along a year later and added a new line:
>
> template<typename T>
> void ProcessNode(T &&arg)
> {
> NormaliseNode(arg);
> DistributeNode(arg);
> AssimilateNode( forward<T>(arg) );
> TrimMemoryUsage( forward<T>(arg) );
> }
>
> Of course this is a very very simple example, and Mandy would be able
> to see straight away that 'arg' was already forwarded on the previous
> line. But what if the function were 340 lines long, and what if Mandy
> missed that 'arg' had previously been forwarded. This bug could lead
> to the building of an executable binary that doesn't crash, but
> behaves oddly only for a few corner cases. The person tasked with
> fixing this bug might spend a long time trying to figure out what's
> gone wrong.
>
> The whole point of the trigraph reference is that it means that the
> programmer can no longer make the mistake.
>
I strongly recommend that you don't keep calling these digraphs and
trigraphs, those are pre-existing terms with a specific (and very
different) meaning.
Nobody says "digraph reference" when they mean forwarding reference or
universal reference or rvalue reference.
More generally, I agree that it's not worth introducing a whole new
language feature just to get the compiler to auto-forward in exactly one
place. It seems like a job for analyzers/linters or just compiler warnings.
Received on 2025-04-10 10:32:16