First life-signs of type functions

Steven Schveighoffer schveiguy at gmail.com
Tue May 12 19:15:54 UTC 2020


On 5/12/20 1:32 PM, Johannes Loher wrote:
> On Tuesday, 12 May 2020 at 16:12:42 UTC, Steven Schveighoffer wrote:
>> I can totally envision this pattern happening:
>>
>> string foo(string[] symbolnames, alias dummy = __dummy)
>> {
>>    // do something with symbolnames, ignore dummy
>> }
>>
>> to force a type function instead of using CTFE when you want to 
>> manipulate a compile-time list of strings.
>>
> 
> Why would you ever do this? To enforce that the function is only called 
> at compile time?

I'm assuming in type functions we have further leeways that aren't 
available in CTFE functions. Like, for instance, 
SomeTemplate!(symbolnames[0]) should be doable in a type function, but 
would not be doable in a CTFE function.

Not sure if that would require symbolnames be an alias[] or not.

> Looks like a hack to a problem we should have a proper 
> solution for instead.

I agree, which is why I brought it up.

-Steve


More information about the Digitalmars-d mailing list