On Tuesday, 1 July 2014 at 13:53:12 UTC, Ali Çehreli wrote:
On 07/01/2014 03:21 AM, Puming wrote:

> I can safely assume ref is better than pointer here

I agree.

> because it plays nicely with UFCS.

I don't understand that part. :) The following is the same program with just two differences: prompt() takes a pointer and 'server' is a pointer.

import std.conv;

struct Server
{
    string name;
    string ip;
    int port;
    string user;
}

string prompt(Server * server)
{
return server.user ~ "@" ~ server.ip ~ ":" ~ server.port.to!string;
}

void main()
{
auto server = new Server("bzzt", "192.168.0.1", 80, "nobody");
    string p = server.prompt;
}

Ali

Wow, I've tested with some other code and pointer did not work, maybe I got something else wrong. Anyway, it's nice to know pointers also works with UFCS :-)

Reply via email to