New operators opStaticIndex and friends

Q. Schroll qs.il.paperinik at gmail.com
Wed May 15 12:05:26 UTC 2019


On Wednesday, 15 May 2019 at 01:42:57 UTC, Exil wrote:
> On Wednesday, 15 May 2019 at 01:07:10 UTC, Q. Schroll wrote:
>
> Does it need to be called opStaticIndex? Could it just be 
> called opIndex and require the specific template arguments. If 
> you define opIndex(int)() now, it will never be called right 
> (unless you specifically invoke it)?

I've thought about it and concluded the answer is no.

For dynamic indexing (i.e. current state opIndex and friends) 
most of them (everything except opDollar) must be some kind of 
function (i.e. functions, function templates, something with 
opCall, ... you name it), as it is rewritten to a function call.
With opStaticIndex, apart from opStaticIndex(Op)Assign, where the 
right-hand side is still a function parameter, it could be 
implemented by an enum or alias or something like that (cf. 
current state opDollar).
You cannot overload functions with enums or something the like.
Then you need two different names.
You could fallback to that if the opStatic.. ones are not there, 
but that complicates the DIP even more.

I'd stay with the proposed names or change them to something 
different, but not reuse something that currently exists.


More information about the Digitalmars-d mailing list