New operators opStaticIndex and friends

Q. Schroll qs.il.paperinik at gmail.com
Fri May 17 17:41:26 UTC 2019


On Thursday, 16 May 2019 at 22:26:34 UTC, Exil wrote:
> This doesn't help with the explanation, what special syntax? 
> Maybe an example that works with opStaticIndex and that 
> wouldn't work with opIndex would help. Otherwise I still don't 
> see a problem.

Simple answer is: You cannot overload opIndex aliasing a data 
member and opIndex being a function. If it is a function 
somewhere, it *must* always be a function in that aggregate 
(struct/union/class/interface).

It is more flexible not having a name clash. It's easier to learn 
and reason about, too. To me, it has literally no benefit using 
opIndex for static indexing.

Part of a working example: https://run.dlang.io/is/274pNN


More information about the Digitalmars-d mailing list