On Tuesday, 3 October 2023 at 18:09:55 UTC, Imperatorn wrote:
At the very least, the spec should do a better job of documenting when the compiler will try a fallback and when it won't.

Who will be the hero and add the documentation? 😇


More importantly, is there a priority order? Because in our last example, when we leave a single overload, all features are executed through the ref opIndex except the bit:

```d
struct S
{
  int[] i;

  ref opIndex(size_t index) => i[index];

  //void opIndexAssign(int value) { i[] = value; }
  //void opIndexAssign(int value, size_t idx) { i[idx] = value; }
}

void main()
{
  auto s = S([2, 2]);

  s[0] = 2;
  assert(s.i == [2, 2]);

  s[1] = 42;
  assert(s.i == [2, 42]);

  s[0]++;
  assert(s.i == [3, 42]);

  s[0] += 1;
  assert(s.i == [4, 42]);
}
```

So the important thing is: Who is dominant when another overload comes into play?

SDB@79

Reply via email to