What type functions mean on a language level

Stefan Koch uplink.coder at googlemail.com
Wed Jan 13 17:09:59 UTC 2021


On Tuesday, 12 January 2021 at 20:41:02 UTC, Q. Schroll wrote:
> On Wednesday, 6 January 2021 at 13:52:39 UTC, sighoya wrote:
>> If we allow a __type__ in type position, indirectly or 
>> directly, we're able to implement generics known from other 
>> languages, e.g.:
>>
>> ```
>> method(__type__ type)(type value){...}
>> ```
>> vs
>>
>> ```
>> method(T)(T value){...}
>> ```
>
> Is this a suggestion or what you think the semantics' 
> consequences are? Because I fail to see how the first one is 
> any different from a template. If I replace `__type__ type` by 
> `int i`, it is still a compile-time argument. In one instance, 
> the value argument is (or represents) a type. That doesn't 
> change the semantics, or does it?

A value type can only be used as type if it a statically known 
value,
which in the above example is the case.
But I doubt it will work with the ITFI functionality as it is 
currently implemented.

I have never intended this usecase, I think that we should be 
able to get it to work,
but I am not sure if that's the most productive thing to do.



More information about the Digitalmars-d mailing list