C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit this

From: Andrew Tomazos <andrewtomazos_at_[hidden]>
Date: Mon, 3 Apr 2023 22:04:47 +1000
To be fair to the OP, even though he doesn't know about explicit object
parameters yet, they were not designed for his use case. I think he wants
to force people to put `this->` in front of member names, because he thinks
it makes the code more readable (by making member names visually distinct
from non-member names). The solution of always using explicit object
parameters sort of achieves this goal, but requires additional syntax of
declaring the explicit object parameter in every function, and declaring a
new and potentially-unique name for it in every member function. While,
granted, conventionally you could always call it `self`, it's still not as
good as using the long-standing and familiar syntax of `this->`.

On Mon, Apr 3, 2023 at 9:43 PM Gašper Ažman via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> How about "just use an explicit-object function" and then bodies behave
> like they do in free functions?
>
> This is basically what Ville told you to do, as well.
>
> On Mon, Apr 3, 2023 at 12:41 PM Bo Persson via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> On 2023-04-03 at 12:40, Frederick Virchanza Gotham via Std-Proposals
>> wrote:
>> > On Mon, Apr 3, 2023 at 11:20 AM Ville Voutilainen
>> > <ville.voutilainen_at_[hidden]> wrote:
>> >>
>> >> Looks like you're failing to see the point. When you write it
>> >> correctly, that is,
>> >>
>> >> return ::Monkey::Func();
>> >>
>> >> you know that's a non-member function because it has a :: in the very
>> >> beginning, so it can't
>> >> be a member function of the current class or of a base class.
>> >
>> >
>> > I understood the point. The counter-point I was making was that you
>> > sometimes needed to prepend something more complicated than "::".
>> >
>>
>> So the solution to "sometimes needed to prepend something more
>> complicated" is to *always* prepend this-> to everything else.
>>
>> Doesn't seem like a simplification to me.
>>
>>
>>
>> --
>> 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
>

Received on 2023-04-03 12:05:03