Re: Pass 'this' as reference

2018-09-19 Thread Jan via Digitalmars-d-learn
On Saturday, 15 September 2018 at 20:13:51 UTC, Jonathan M Davis wrote: On Saturday, September 15, 2018 11:44:05 AM MDT Jan via Digitalmars-d-learn wrote: [...] No. variables are _always_ lvalues. An lvalue is an object which is addressable and which can therefore be assigned a value

Re: Pass 'this' as reference

2018-09-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 15, 2018 11:44:05 AM MDT Jan via Digitalmars-d-learn wrote: > On Thursday, 13 September 2018 at 11:08:30 UTC, Jonathan M Davis > > wrote: > > [...] > > Thanks for clarifying Jonathan :) > But aren't the variables considered rvalues then? No. variables are _always_ lvalues.

Re: Pass 'this' as reference

2018-09-15 Thread Jan via Digitalmars-d-learn
On Thursday, 13 September 2018 at 11:08:30 UTC, Jonathan M Davis wrote: [...] Thanks for clarifying Jonathan :) But aren't the variables considered rvalues then?

Re: Pass 'this' as reference

2018-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 13, 2018 4:04:58 AM MDT Jan via Digitalmars-d-learn wrote: > Many thanks Adam and Steve! Works like a charm! :D > I presumed classes are lvalues. I shouldn't make things more > complicated than they are ;-) Well, the variables _are_ lvalues. It's just that they're

Re: Pass 'this' as reference

2018-09-13 Thread Jan via Digitalmars-d-learn
Many thanks Adam and Steve! Works like a charm! :D I presumed classes are lvalues. I shouldn't make things more complicated than they are ;-)

Re: Pass 'this' as reference

2018-09-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/12/18 8:01 AM, Jan wrote: I'm using D not for that long and lately I have encountered an issue. I have class 'Foo' with a constructor using this signature: `this (ref Bar original)` In the 'Bar' class itself I want to create an instance of 'Foo' using 'this' as parameter. Something in

Re: Pass 'this' as reference

2018-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 September 2018 at 15:01:36 UTC, Jan wrote: I'm using D not for that long and lately I have encountered an issue. I have class 'Foo' with a constructor using this signature: `this (ref Bar original)` classes and the ref keyword should very rarely be used together in D.

Pass 'this' as reference

2018-09-12 Thread Jan via Digitalmars-d-learn
I'm using D not for that long and lately I have encountered an issue. I have class 'Foo' with a constructor using this signature: `this (ref Bar original)` In the 'Bar' class itself I want to create an instance of 'Foo' using 'this' as parameter. Something in the way of: `Foo foo = new