Calls `this(this)` extra with delegate stuff in the code

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 21 19:22:58 PST 2017


On Sunday, 22 January 2017 at 00:31:38 UTC, Ali Çehreli wrote:
> On 01/21/2017 03:36 PM, Ali Çehreli wrote:
>
> > Change the signature and it works without copies:
> >
> >     this(const(this)) {
> >         // ...
> >     }
>
> Ugh... :( It's not a post-blit. Then what is it?
>
> Ali

This is a __ctor that takes another instance as param. The param 
name is not specified, i.e

struct Foo
{
     this(const(this)){}
}

is the same as

struct Foo
{
     this(const(this) param){}
}

since __PRETTY__FUNCTION__ in the function returns

     "Foo Foo.this(const(Foo) _param_0) ref"

That's strange.
Isn't it mentioned somewhere in the specification that within a 
function declaration, "this" resolves to the type of the current 
aggregate ?


More information about the Digitalmars-d-learn mailing list