Date: Sun, 27 Apr 2025 13:22:09 -0400
On Sun, Apr 27, 2025 at 12:42 PM Tiago Freire via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> > Why do you want different things to pretend they're the same thing? If
> you want the language to be changed, you need to offer a reason why it
> would be good, not simply "why not".
>
> My proposition was that because it could produce smaller binaries (and
> allow for better code optimization) is itself reason enough to make the
> change.
>
> And I'm trying to challenge this idea that "functions have different names
> and therefore should have different addresses, just because".
>
> Same logic applies as to why zero size objects shouldn't have at least
> 1byte. no_unique_address should be the default and not the opt-in exception
> IMO.
>
> > Because the language is supposed to actually make sense.
>
> I don't see a reason why a programming language couldn't be coherent if
> &foo != &bar is undefined behavior.
>
> > If you want two different declarations with different names to denote
> the same entity... shouldn't the user actually, *explicitly* request that?
> What even is a declaration or a name if it doesn't represent a specific,
> distinct entity?
>
> A function is not an object, it is a function.
> There's no reason to reason about functions as if they were objects.
>
> > But they don't happen behind the user's back;
>
> It already happens behind the user's back. You are not able to define what
> is the exact address of your function, or if one even exists at all. Why
> would removing the guarantee that it is unique would make a difference?
>
In
https://github.com/bloomberg/bde/blob/main/groups/bsl/bsltf/bsltf_templatetestfacility.h#L1285
we use the fact that different functions have different addresses to
produce 128 unique values of type `TemplateTestFacility::MethodPtr` (which
is a typedef to a pointer to member function), which are then used to test
e.g. containers that must work with various kinds of element types.
>
>
> ------------------------------
> *From:* Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf
> of Jason McKesson via Std-Proposals <std-proposals_at_[hidden]>
> *Sent:* Sunday, April 27, 2025 4:46:59 PM
> *To:* std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> *Cc:* Jason McKesson <jmckesson_at_[hidden]>
> *Subject:* [std-proposals] Fwd: Fwd: [std-discussion] Guarantees over
> addresses from function pointers created from lambda
>
> On Sun, Apr 27, 2025 at 10:42 AM Tiago Freire <tmiguelf_at_[hidden]>
> wrote:
> >
> > > By the rules of C++, if you test the addresses of these two objects,
> they *must* be different.
> >
> > Again why? I know that is what it does now, but why is it important to
> behave this way?
>
> Why do you want different things to pretend they're the same thing? If
> you want the language to be changed, you need to offer a reason why it
> would be good, not simply "why not".
>
> > > Because they have different names which
> > denote different entities *even if* the result of evaluating them is
> known by the compiler to be the same.
> >
> > Why would that matter?
>
> Because the language is supposed to actually make sense. If you want
> two different declarations with different names to denote the same
> entity... shouldn't the user actually, *explicitly* request that? What
> even is a declaration or a name if it doesn't represent a specific,
> distinct entity?
>
> We have a way to create a name that denotes an existing (object)
> entity: references. But they don't happen behind the user's back;
> there's special syntax for creating them.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
std-proposals_at_[hidden]> wrote:
> > Why do you want different things to pretend they're the same thing? If
> you want the language to be changed, you need to offer a reason why it
> would be good, not simply "why not".
>
> My proposition was that because it could produce smaller binaries (and
> allow for better code optimization) is itself reason enough to make the
> change.
>
> And I'm trying to challenge this idea that "functions have different names
> and therefore should have different addresses, just because".
>
> Same logic applies as to why zero size objects shouldn't have at least
> 1byte. no_unique_address should be the default and not the opt-in exception
> IMO.
>
> > Because the language is supposed to actually make sense.
>
> I don't see a reason why a programming language couldn't be coherent if
> &foo != &bar is undefined behavior.
>
> > If you want two different declarations with different names to denote
> the same entity... shouldn't the user actually, *explicitly* request that?
> What even is a declaration or a name if it doesn't represent a specific,
> distinct entity?
>
> A function is not an object, it is a function.
> There's no reason to reason about functions as if they were objects.
>
> > But they don't happen behind the user's back;
>
> It already happens behind the user's back. You are not able to define what
> is the exact address of your function, or if one even exists at all. Why
> would removing the guarantee that it is unique would make a difference?
>
In
https://github.com/bloomberg/bde/blob/main/groups/bsl/bsltf/bsltf_templatetestfacility.h#L1285
we use the fact that different functions have different addresses to
produce 128 unique values of type `TemplateTestFacility::MethodPtr` (which
is a typedef to a pointer to member function), which are then used to test
e.g. containers that must work with various kinds of element types.
>
>
> ------------------------------
> *From:* Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf
> of Jason McKesson via Std-Proposals <std-proposals_at_[hidden]>
> *Sent:* Sunday, April 27, 2025 4:46:59 PM
> *To:* std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> *Cc:* Jason McKesson <jmckesson_at_[hidden]>
> *Subject:* [std-proposals] Fwd: Fwd: [std-discussion] Guarantees over
> addresses from function pointers created from lambda
>
> On Sun, Apr 27, 2025 at 10:42 AM Tiago Freire <tmiguelf_at_[hidden]>
> wrote:
> >
> > > By the rules of C++, if you test the addresses of these two objects,
> they *must* be different.
> >
> > Again why? I know that is what it does now, but why is it important to
> behave this way?
>
> Why do you want different things to pretend they're the same thing? If
> you want the language to be changed, you need to offer a reason why it
> would be good, not simply "why not".
>
> > > Because they have different names which
> > denote different entities *even if* the result of evaluating them is
> known by the compiler to be the same.
> >
> > Why would that matter?
>
> Because the language is supposed to actually make sense. If you want
> two different declarations with different names to denote the same
> entity... shouldn't the user actually, *explicitly* request that? What
> even is a declaration or a name if it doesn't represent a specific,
> distinct entity?
>
> We have a way to create a name that denotes an existing (object)
> entity: references. But they don't happen behind the user's back;
> there's special syntax for creating them.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
-- *Brian Bi*
Received on 2025-04-27 17:22:24