Have you considered the multiple indexes?

  https://dlang.org/spec/operatoroverloading.html#index_assignment_operator

It may give you some power in execution order.

import std.stdio;

struct S {
    auto opIndex(string index) {
        writeln(index);
        return 42;
    }

    auto opIndexAssign(int value, string[] indexes...) {
        writeln(indexes);
    }
}

void main() {
    auto s = S();
    s["b", "c"] = s["a"];
}

Prints

a
["b", "c"]

Ali

Reply via email to