template statistics

Stefan Koch uplink.coder at googlemail.com
Wed Jun 3 11:22:23 UTC 2020


On Wednesday, 3 June 2020 at 11:09:56 UTC, jmh530 wrote:
> On Wednesday, 3 June 2020 at 04:52:37 UTC, Stefan Koch wrote:
>> [snip]
>>
>> If the template sounds like a question about a type,
>> Like (CharTypeof or isIntegral) it probably should not be a 
>> template.
>
>
> I was a little confused by this.
>
> Given your recent work on type functions, do you mean that type 
> functions should replace templates in situations like that? 
> That would imply that things like `isIntegral` has to be a 
> template now, but could be changed in the future, correct? Do 
> you think something like mir's `sumType` [1] should not be a 
> template?
>
>
> [1] 
> https://github.com/libmir/mir-algorithm/blob/f111c311eadb0057f5a233c156b772a010ceab71/source/mir/math/sum.d#L1986

Oh yes.
sumType does not need to introduce new symbols.
Therefore it should be handled in a way which does not introduce 
new symbols.

type functions are one way to make this happen.
However changes to the language are hard justify therefore I am 
currently revisiting,
approaches to infer type-function-like behavior and transform 
them behind the scenes.
(Which is a HUGE pain, because you have to transform recursion 
into loops, which is a hard problem in itself, AND the user 
probably would rather have written a loop, but was forced by the 
language to use recursion. )

alas having my work being useful in the language is more 
important than to have a better language.

I will continue on type functions; if the conservative approaches 
don't work out.


More information about the Digitalmars-d mailing list