[Issue 16302] Add opStaticIndex that takes compile-time indices
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat May 13 10:12:53 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=16302
--- Comment #7 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Yuxuan Shui from comment #6)
> I want to suggest we just reuse opIndex. If opIndex is defined as a
> template, the static semantic is used.
This is a good idea.
s[arg1, arg2] is lowered to opIndex(arg1, arg2)
the compiler could try opIndex!(arg1, arg2) if it applies, otherwise fall back
on the normal opIndex.
Where I am concerned is the case where runtime indexing accepts template
parameters. However, in those cases, the template parameters must all be types,
and implied via IFTI, meaning it has runtime parameters that match each type.
The static opIndex needs to have zero runtime parameters ALWAYS. I think it
still can work.
I'd like to continue having the slice usage that is so flexible in the current
implementation at compile-time as well.
--
More information about the Digitalmars-d-bugs
mailing list