Date: Mon, 10 Feb 2025 03:47:47 +0000
On Saturday, February 8th, 2025 at 6:57 AM, Tiago Freire via Std-Proposals <std-proposals_at_[hidden]> wrote:
> Does the proposal improve clarity? No.
> Does the proposal allows you do something new or solve a problem? No.
It has an opportunity to give you a different angle ofviewing a program.
Many believe that the unique syntax of pointers made
the unique semantics of pointers stand out. That is true
only if you believe that the semantics of pointers are
unique. But to me, there is only one semantics that sits
in the center: reference semantics. The rest are properties.
Both C++ references and pointers have reference semantics.
C++ references are non-nullable and rebindable, pointers
are nullable and rebindable, std::reference_wrapper is
non-nullable and rebindable. You can reach the same
conclusion if keep the syntax out for a moment.
But what does the syntax difference trouble me, then?
It undermines the possible gain of making a different choice
between pointers and references and overstates the cost
by dividing them into two languages linguistically. Consider
a function that takes an output parameter as a reference.
What does it mean if you change that to a pointer? It means
you want nullable and rebindable. What about the opposite?
If the function was written in dot-only style, taking the
parameter as a reference instead of pointers means removing
the nullable and rebindable properties. If it fits your
goal, then change one symbol, done deal.
Taking away the emphasis of nullable from the pointer's
use-syntax can also allow human readers to focus on important
aspects when reading some program style. For example,
if (auto result = get_if(my_variant))
use(result.x);
> Other than "it saves me to type only 1 character instead of 2", what would I as a software developer writing C++ gain from this?
>
> Does the proposal improve clarity? No.
> Does the proposal allows you do something new or solve a problem? No.
It has an opportunity to give you a different angle ofviewing a program.
Many believe that the unique syntax of pointers made
the unique semantics of pointers stand out. That is true
only if you believe that the semantics of pointers are
unique. But to me, there is only one semantics that sits
in the center: reference semantics. The rest are properties.
Both C++ references and pointers have reference semantics.
C++ references are non-nullable and rebindable, pointers
are nullable and rebindable, std::reference_wrapper is
non-nullable and rebindable. You can reach the same
conclusion if keep the syntax out for a moment.
But what does the syntax difference trouble me, then?
It undermines the possible gain of making a different choice
between pointers and references and overstates the cost
by dividing them into two languages linguistically. Consider
a function that takes an output parameter as a reference.
What does it mean if you change that to a pointer? It means
you want nullable and rebindable. What about the opposite?
If the function was written in dot-only style, taking the
parameter as a reference instead of pointers means removing
the nullable and rebindable properties. If it fits your
goal, then change one symbol, done deal.
Taking away the emphasis of nullable from the pointer's
use-syntax can also allow human readers to focus on important
aspects when reading some program style. For example,
if (auto result = get_if(my_variant))
use(result.x);
> Other than "it saves me to type only 1 character instead of 2", what would I as a software developer writing C++ gain from this?
>
-- Zhihao Yuan, ID lichray The best way to predict the future is to invent it. _______________________________________________
Received on 2025-02-10 03:47:57