On Saturday, 14 April 2012 at 15:35:13 UTC, Andrej Mitrovic wrote:
On 4/14/12, F i L <[email protected]> wrote:
This is exactly what I'm trying to get at.

Anyway it's not all bad news since we can use a workaround:

struct Float {
    float payload = 0.0;
    alias payload this;
}

void main() {
    Float x;  // acts as a float, is initialized to 0.0
}

Not pretty, but it comes in handy.

Lol, that's kinda an interesting idea:

    struct var(T, T def) {
        T payload = def;
        alias payload this;
    }

    alias var!(float,  0.0f) Float;
    alias var!(double, 0.0)  Double;
    alias var!(real,   0.0)  Real;
    alias var!(char,   ' ')  Char;

    void main() {
        Float f;
        assert(f == 0.0f);
    }

a Hack though, since it doesn't work with 'auto'. I still think it should be the other way around, and this should be used to Default to NaN.

Reply via email to