C++ Logo

std-proposals

Advanced search

Re: Do we need a way to take *this by value, for coroutines?

From: Gašper Ažman <gasper.azman_at_[hidden]>
Date: Mon, 8 Nov 2021 16:32:43 +0000
It has been discussed and rejected *for now*, but the design space there
has been left open.

There's nothing preventing us from doing something like that in a future
version of C++.

On Mon, Nov 8, 2021 at 4:30 PM Phil Endecott <
std_proposals_list_at_[hidden]> wrote:

> Gašper Ažman wrote:
> > The committee actually did look at the (F this) syntax and it took a long
> > time to convince them that it's a bad idea.
>
> It's the lack of plain access to members without having
> to write this-> or this. or self. that I regret losing.
> I.e. I don't want to be able to write "this.foo" in
> preference to "self.foo" in such a method, I want to be
> able to just write "foo".
>
> I have sometimes wondered whether it would he helpful to
> provide syntax to bring arbitrary objects' members into
> scope. Without this, free functions are inherently more
> verbose than methods. I think that Pascal and/or Modula-2
> had a "with" statement that allowed this. Example:
>
> struct Circle {
> float r;
> float area() const { return pi*r*r; } // concise
> };
>
> float area(const Circle& circle)
> {
> return pi*circle.r*circle.r; // verbose
> }
>
> float area(const Circle& circle)
> {
> with circle {
> return pi*r*r; // concise
> }
> }
>
> You'll probably tell me this was considered and rejected years ago...
>
>
> Regards, Phil.
>
>
>
>
>

Received on 2021-11-08 10:32:57