Re: alias this - am I using it wrong?

2021-08-25 Thread Johann Lermer via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 12:23:06 UTC, Adam D Ruppe wrote: ... Thanks - that explains in all. On Wednesday, 25 August 2021 at 12:23:32 UTC, FeepingCreature wrote: class Alias_Class { Test_Struct ts; Test_Struct getter() { return ts; } alias getter this; } Good idea,

Re: alias this - am I using it wrong?

2021-08-25 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 12:23:06 UTC, Adam D Ruppe wrote: [snip] That's a lot about alias this that I didn't know. Thanks.

Re: alias this - am I using it wrong?

2021-08-25 Thread FeepingCreature via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 12:11:01 UTC, Johann Lermer wrote: Hi all, I have a little problem understanding alias this. I always thought, that alias this only makes implicit conversions from the aliased object to this. Then, why do lines 18 and 22 compile in the code below? And, btw,

Re: alias this - am I using it wrong?

2021-08-25 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 12:11:01 UTC, Johann Lermer wrote: I have a little problem understanding alias this. I always thought, that alias this only makes implicit conversions from the aliased object to this. What it does is if "a SOMETHING b" doesn't compile, it instead tries

Re: alias this - am I using it wrong?

2021-08-25 Thread jfondren via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 12:11:01 UTC, Johann Lermer wrote: ```d 14 void main () 15 { 16 auto ac = new Alias_Class; 17 Test_Struct ts = ac; // compiles 18 ac = ts; // compiles as well - why? 19 20 auto tc = new Test_Class; 21 ts = tc.ac; //

alias this - am I using it wrong?

2021-08-25 Thread Johann Lermer via Digitalmars-d-learn
Hi all, I have a little problem understanding alias this. I always thought, that alias this only makes implicit conversions from the aliased object to this. Then, why do lines 18 and 22 compile in the code below? And, btw, line 22 crashes with a segmentation fault. ```d 01 struct