The difference between T[] opIndex() and T[] opSlice()
Paul Backus
snarwin at gmail.com
Tue Oct 3 17:52:20 UTC 2023
On Tuesday, 3 October 2023 at 16:45:39 UTC, Steven Schveighoffer
wrote:
>
> OK, so it's not as bad as I thought, but surely the compiler
> should recognize that `opIndexAssign(val, idx)` doesn't work,
> but `opIndex(idx) = val` does?
Maybe. On the other hand, if you make a typo in the body of your
templated `opIndexAssign` overload, do you want the compiler to
silently fall back to `opIndex`, or do you want an error? There
are pros and cons to both approaches.
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.
More information about the Digitalmars-d-learn
mailing list