Re: Fighting with alias this: bugs or features?

2010-10-27 Thread Steven Schveighoffer
On Tue, 26 Oct 2010 12:35:21 -0400, osa wrote: Every time I'm trying to use alias this (which looks like a nice feature, on paper), I end up with problems. This is the most recent one (dmd v2.049): -- struct Foo {} class Bar { Foo foo_; alias foo_ this; } void main() { a

Re: Fighting with alias this: bugs or features?

2010-10-27 Thread trx1
osa Wrote: > On 10/26/2010 05:09 PM, Andrei Alexandrescu wrote: > > Thanks. Defining opAssign for Bar will allow you to use the syntax bar = > > null and have it nullify the reference. > > I feel stupid, but I do not see how to nullify the Bar reference inside > of opAssign. Again, my problem is

Re: Fighting with alias this: bugs or features?

2010-10-26 Thread Andrei Alexandrescu
On 10/26/10 17:29 CDT, osa wrote: On 10/26/2010 05:09 PM, Andrei Alexandrescu wrote: Thanks. Defining opAssign for Bar will allow you to use the syntax bar = null and have it nullify the reference. I feel stupid, but I do not see how to nullify the Bar reference inside of opAssign. Again, my p

Re: Fighting with alias this: bugs or features?

2010-10-26 Thread osa
On 10/26/2010 05:09 PM, Andrei Alexandrescu wrote: Thanks. Defining opAssign for Bar will allow you to use the syntax bar = null and have it nullify the reference. I feel stupid, but I do not see how to nullify the Bar reference inside of opAssign. Again, my problem is that I have Bar

Re: Fighting with alias this: bugs or features?

2010-10-26 Thread Andrei Alexandrescu
On 10/26/10 16:58 CDT, osa wrote: On 10/26/2010 04:46 PM, Andrei Alexandrescu wrote: In this particular case the decision goes both ways, and both have something going for them. You may want to submit a bug report at least to prompt us to change the documentation to clarify the behavior. A worka

Re: Fighting with alias this: bugs or features?

2010-10-26 Thread osa
On 10/26/2010 04:46 PM, Andrei Alexandrescu wrote: In this particular case the decision goes both ways, and both have something going for them. You may want to submit a bug report at least to prompt us to change the documentation to clarify the behavior. A workaround is to define opAssign(Bar).

Re: Fighting with alias this: bugs or features?

2010-10-26 Thread Andrei Alexandrescu
On 10/26/10 11:35 CDT, osa wrote: Every time I'm trying to use alias this (which looks like a nice feature, on paper), I end up with problems. This is the most recent one (dmd v2.049): -- struct Foo {} class Bar { Foo foo_; alias foo_ this; } void main() { auto a = new Bar; auto b = a; a = n

Re: Fighting with alias this: bugs or features?

2010-10-26 Thread osa
On 10/26/2010 03:22 PM, "Jérôme M. Berger" wrote: I'm not sure that the problem is on the line where the error is reported. My guess would be that the issue is with the "auto a = new Bar" line: I would bet that this gets interpreted as "Foo a = new Bar" instead of what we expect ("Bar a =

Re: Fighting with alias this: bugs or features?

2010-10-26 Thread Jérôme M. Berger
Jonathan M Davis wrote: > On Tuesday, October 26, 2010 09:35:21 osa wrote: >> Every time I'm trying to use alias this (which looks like a nice >> feature, on paper), I end up with problems. This is the most recent one >> (dmd v2.049): >> -- >> struct Foo {} >> class Bar { >> Foo foo_; >>

Re: Fighting with alias this: bugs or features?

2010-10-26 Thread Jonathan M Davis
On Tuesday, October 26, 2010 09:35:21 osa wrote: > Every time I'm trying to use alias this (which looks like a nice > feature, on paper), I end up with problems. This is the most recent one > (dmd v2.049): > -- > struct Foo {} > class Bar { > Foo foo_; > alias foo_ this; > } > > void

Fighting with alias this: bugs or features?

2010-10-26 Thread osa
Every time I'm trying to use alias this (which looks like a nice feature, on paper), I end up with problems. This is the most recent one (dmd v2.049): -- struct Foo {} class Bar { Foo foo_; alias foo_ this; } void main() { auto a = new Bar; auto b = a; a = null; // fails