DIP 1020--Named Parameters--Community Review Round 2
rikki cattermole
rikki at cattermole.co.nz
Tue Sep 17 13:58:06 UTC 2019
On 18/09/2019 1:52 AM, jmh530 wrote:
> On Tuesday, 17 September 2019 at 13:36:59 UTC, rikki cattermole wrote:
>> [snip]
>>
>> So with signatures you essentially need a separate parameter type
>> which says: will probably be inferred from something but can be set by
>> the user if they really need to.
>>
>> In your above example, I suspect it will have name collisions as-is.
>>
>> [snip]
>
> Would it help to use opDispatch? Maybe something like below (assuming
> types are first class objects):
>
> struct Foo(T) {
> type opDispatch(string U)()
> if (is(T == mixin(U))
> {
> return mixin(U);
> }
> }
Yes.
But as a language feature I have no idea what first class types would do
in D.
For example:
alias Foo(T) = T.U;
in long form:
template Foo(T) {
alias Foo = T.U;
}
So we already have "functions" that return types+constants already.
More information about the Digitalmars-d
mailing list