Modify Object Pointer during Initialzation

Jeroen Bollen jbinero at gmail.com
Tue Apr 8 07:23:01 PDT 2014


On Tuesday, 8 April 2014 at 14:13:10 UTC, Adam D. Ruppe wrote:
> On Tuesday, 8 April 2014 at 14:04:01 UTC, Jeroen Bollen wrote:
>> Basically, why is this its own variable? Why doesn't D simply 
>> use the variable it was called with?
>
> A class reference is basically a pointer, passing it by 
> reference to each method would be a double pointer and wasted 
> effort most the time; all most methods care about is where to 
> get the object data, they don't need to know how the caller was 
> getting to the object data.
>
>> I don't see why this needs to be a new variable and cannot 
>> simply be 'passed-by-reference'.
>
> You can get that with UFCS btw:
>
> class A {}
>
> void f(ref A a) { /* modify a here and it will change */ }
>
> void main() {
>   A a = new A;
>   a.f; // a is passed by reference
> }

Is there a documentation page about the 'uniform function call 
syntax'?


More information about the Digitalmars-d-learn mailing list