Re: Cannot pass by reference

2013-11-18 Thread Jeroen Bollen
On Saturday, 16 November 2013 at 16:34:31 UTC, Ali Çehreli wrote: The problem with your example is that unlike main.c in my example, what you pass is an rvalue, which may not be bound to the ref parameter. Thanks, this is what I needed!

Re: Cannot pass by reference

2013-11-17 Thread Andrej Mitrovic
On 11/17/13, Ali Çehreli wrote: > It allows changing the actual object that the caller had. Technically no, it changes the reference in the caller, not the actual object itself. That object is likely still alive until collected if there are no other references to it.

Re: Cannot pass by reference

2013-11-17 Thread Meta
On Sunday, 17 November 2013 at 07:32:22 UTC, Ali Çehreli wrote: It allows changing the actual object that the caller had. Oh, right. I don't think I've ever done that before in any language. Thanks.

Re: Cannot pass by reference

2013-11-16 Thread Ali Çehreli
On 11/16/2013 11:21 PM, Meta wrote: >> First, just a reminder: Classes in D are reference types so in most >> cases there is no need for ref; it already is a reference to the >> actual object. > > Just out of curiosity, what does ref Object actually do? It allows changing the actual object that

Re: Cannot pass by reference

2013-11-16 Thread Meta
First, just a reminder: Classes in D are reference types so in most cases there is no need for ref; it already is a reference to the actual object. Just out of curiosity, what does ref Object actually do? Is it just a no-op?

Re: Cannot pass by reference

2013-11-16 Thread Ali Çehreli
On 11/16/2013 06:08 AM, Jeroen Bollen wrote: I cannot seem to pass values to functions by referece. -- @safe public nothrow this(ref Socket socket) { // Inside class modulename.classname this.

Re: Cannot pass by reference

2013-11-16 Thread bearophile
Jeroen Bollen: Same error, but "is not callable using argument types (TcpSocket)"... Have you used an auxiliary value inside the main with the cast? Bye, bearophile

Re: Cannot pass by reference

2013-11-16 Thread Jeroen Bollen
On Saturday, 16 November 2013 at 14:28:45 UTC, bearophile wrote: Jeroen Bollen: Why is that? It's caused by the cast. The solution is to use an auxiliary value inside the main, or remove the cast. Bye, bearophile Same error, but "is not callable using argument types (TcpSocket)"...

Re: Cannot pass by reference

2013-11-16 Thread bearophile
Jeroen Bollen: Why is that? It's caused by the cast. The solution is to use an auxiliary value inside the main, or remove the cast. Bye, bearophile