Passing and returning arguments by ref

Joe jma at fc.com
Fri Mar 3 20:45:39 UTC 2023


Thanks, Ali.

On Friday, 3 March 2023 at 18:09:01 UTC, Ali Çehreli wrote:

> Think may be due to D not having reference variables. Sometimes 
> one needs to use pointers.

Ah! I'm about five chapters away from Pointers ;-).

Actually, I had tried changing B.x1() to:

   `ref X x1() { return &xs[0]; }`

but the compiler didn't accept it.

It's a bit weird that by taking the address of calling B.x1() and 
thus getting an X*, I had to *dereference* that to pass it to the 
helper function of A.mfd() which actually takes a `ref C` 
argument.


More information about the Digitalmars-d-learn mailing list