Re: alias function this - limitations

2010-06-24 Thread Simen kjaeraas
div0 wrote: I've been having a play and as far as I can tell it looks like aliasing this to a method just doesn't work at all; I think the alias this is being completely ignored. It would seem you're right. Just that assignment made me think it did work. Now why does the assignment work? I

Re: alias function this - limitations

2010-06-24 Thread div0
On 24/06/2010 19:23, Simen kjaeraas wrote: div0 wrote: This code fails on the line 'int b = f;'. Is it supposed to? I think so. 'alias this' is used to forward stuff that appears to the right of a dot onto the named member. Not only. Assignment of the wrapped type will also work. Yes,

Re: alias function this - limitations

2010-06-24 Thread Steven Schveighoffer
On Thu, 24 Jun 2010 14:23:09 -0400, Simen kjaeraas wrote: It does not. In WalterAndrei.pdf, opImplicitCast(To|From) is mentioned, but it has not found its way into the language. Alias this is supposed to implement what opImplicitCast was supposed to implement. opImplicitCast is not going

Re: alias function this - limitations

2010-06-24 Thread Simen kjaeraas
div0 wrote: This code fails on the line 'int b = f;'. Is it supposed to? I think so. 'alias this' is used to forward stuff that appears to the right of a dot onto the named member. Not only. Assignment of the wrapped type will also work. In c++ to get what you are doing to work, you'd

Re: alias function this - limitations

2010-06-24 Thread div0
On 24/06/2010 13:52, Simen kjaeraas wrote: struct Ref( T ) { T* payload; @property ref T getThis( ) { return *payload; } @property ref T getThis( ref T value ) { payload = &value; return *payload; } alias getThis this; } void bar( ) { Ref!int f; int n; f = n; int b = f; } This code fails on the

alias function this - limitations

2010-06-24 Thread Simen kjaeraas
struct Ref( T ) { T* payload; @property ref T getThis( ) { return *payload; } @property ref T getThis( ref T value ) { payload = &value; return *payload; } alias getThis this; } void bar( ) { Ref!int f; int n; f = n; int b = f; } This code fails on the line 'int b