Declare reference to variable ?

bearophile bearophileHUGS at lycos.com
Mon Jul 29 14:37:29 PDT 2013


Temtaime:

> I have a long named variable in a struct.
>
> For example let's name that longnamedstruct.longnamedmember
>
> I need to use that variable in many places of the code and i 
> cannot create the copy of it.

You can shorten the outer name with an alias or "remove" it with 
a with() statement.


> Why i cannot declare reference in D ?

I don't know the reasons. But maybe you can create a little 
struct with just a pointer inside and an alias this to a member 
function that returns a ref.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list