I am actually a little curious why my original approach did not work at all. Using some of what you provided and some of what I had I get the following:

import std.stdio;
import std.string;

class Vector(int N, T) if (N <= 3) {
    T[N] data;

    this()
    {
        data[] = 0;
    }

@property ref T opDispatch(string fieldName, Args ...)(Args args) if (Args.length < 2 && fieldName.length == 1 && toOffset(fieldName) < N)
    {
            int offset = fieldName.charAt(0) - 'x';
            return data[offset] = args[0];
    }
}

void main()
{
        Vector!(2, float) t = new Vector!(2,float)();
        writeln(t.x);
}

Which still errors out with: Error: no property 'x' for type 'test.Vector!(2, float).Vector'

So that is odd.

Reply via email to