digitalmars.D.learn - Modify Object Pointer during Initialzation
- Jeroen Bollen (7/7) Apr 08 2014 This topic is somewhat related to this question I asked yesterday
- Adam D. Ruppe (13/17) Apr 08 2014 A class reference is basically a pointer, passing it by reference
- Jeroen Bollen (3/20) Apr 08 2014 Is there a documentation page about the 'uniform function call
- Adam D. Ruppe (2/4) Apr 08 2014 http://dlang.org/function.html#pseudo-member
- Jeroen Bollen (2/6) Apr 08 2014 Oh beat me to it.
- Jeroen Bollen (2/4) Apr 08 2014 Never mind, I think I understand all there is to it.
This topic is somewhat related to this question I asked yesterday on StackOverflow: http://stackoverflow.com/q/22921395/2558778 Basically, why is this its own variable? Why doesn't D simply use the variable it was called with? https://gist.github.com/Binero/10128826 I don't see why this needs to be a new variable and cannot simply be 'passed-by-reference'.
Apr 08 2014
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 }
Apr 08 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:Is there a documentation page about the 'uniform function call syntax'?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 }
Apr 08 2014
On Tuesday, 8 April 2014 at 14:23:02 UTC, Jeroen Bollen wrote:Is there a documentation page about the 'uniform function call syntax'?http://dlang.org/function.html#pseudo-member
Apr 08 2014
On Tuesday, 8 April 2014 at 14:26:46 UTC, Adam D. Ruppe wrote:On Tuesday, 8 April 2014 at 14:23:02 UTC, Jeroen Bollen wrote:Oh beat me to it.Is there a documentation page about the 'uniform function call syntax'?http://dlang.org/function.html#pseudo-member
Apr 08 2014
On Tuesday, 8 April 2014 at 14:23:02 UTC, Jeroen Bollen wrote:Is there a documentation page about the 'uniform function call syntax'?Never mind, I think I understand all there is to it.
Apr 08 2014