string receiveAll(T)(T socket, int segment_size = 1024)
{
        char[segment_size][] data;
        int cnt = 0;

        while(true)
        {
                auto received = socket.receive(data[cnt]);
                if (received < segment_size)
                        break;  /* early exit */
                else if (!received)
                        break;
                ++cnt;
        }

        return data;
}


This is my theoretical function, it errors at `char[segment_size][] data;` with the painful `app.d(20): Error: variable segment_size cannot be read at compile time` and I recall having an issue similar to this earlier (yesterday) but I don't think any of my solutions seemed valid for this situation.

I understand it's to do with CTFE or some form of compile-time checking but that's really the only thing that annoys me about D, perhaps somebody could link to some resource that explains (not shortly) how to make the D compiler evaluate some things at run-time opposed to compile time.

Perhaps somebody can link some resources e.g. socket servers in D so I can learn how it's implemented by somebody with a bit more experience, or some resources on how to use sockets properly ¯\_(ツ)_/¯

Reply via email to