Thread overview
Early detection of type errors in templates
Sep 14, 2014
bearophile
Sep 17, 2014
Dicebot
Sep 19, 2014
Dicebot
September 14, 2014
This paper suggests a way to improve the detection of errors inside C++-style templated code without reducing expressivity of the templates (and without annotations or Concepts), I presume the same ideas are usable in D:

"Early Detection of Type Errors in C++ Templates" by Sheng Chen, Martin Erwig:
http://web.engr.oregonstate.edu/~erwig/papers/C++TemplateErrors_PEPM14.pdf

Bye,
bearophile
September 14, 2014
On 9/14/14, 3:12 PM, bearophile wrote:
> This paper suggests a way to improve the detection of errors inside
> C++-style templated code without reducing expressivity of the templates
> (and without annotations or Concepts), I presume the same ideas are
> usable in D:
>
> "Early Detection of Type Errors in C++ Templates" by Sheng Chen, Martin
> Erwig:
> http://web.engr.oregonstate.edu/~erwig/papers/C++TemplateErrors_PEPM14.pdf
>
> Bye,
> bearophile

That's a solid paper, thanks. -- Andre
September 17, 2014
On Sunday, 14 September 2014 at 22:12:23 UTC, bearophile wrote:
> This paper suggests a way to improve the detection of errors inside C++-style templated code without reducing expressivity of the templates (and without annotations or Concepts), I presume the same ideas are usable in D:
>
> "Early Detection of Type Errors in C++ Templates" by Sheng Chen, Martin Erwig:
> http://web.engr.oregonstate.edu/~erwig/papers/C++TemplateErrors_PEPM14.pdf
>
> Bye,
> bearophile

I am rather terrible at calculus and math in general, is it possible to provide a very short example of errors that can be detected with such system?
September 17, 2014
On Wednesday, 17 September 2014 at 16:06:06 UTC, Dicebot wrote:
> I am rather terrible at calculus and math in general, is it possible to provide a very short example of errors that can be detected with such system?

Try to read it backwards, and only the last page. Much easier! :-)

It appears to be a type system for reasoning about type safety in generic code without instantiating templates. I guess the most promising possibility is to infer type constraints on parameters directly from the code as well as detecting conflicts (they apparently have discussed something related to this in other papers dealing with "choice types"). But it appears to be a work in progress…

September 19, 2014
On Wednesday, 17 September 2014 at 17:34:29 UTC, Ola Fosheim Grøstad wrote:
> On Wednesday, 17 September 2014 at 16:06:06 UTC, Dicebot wrote:
>> I am rather terrible at calculus and math in general, is it possible to provide a very short example of errors that can be detected with such system?
>
> Try to read it backwards, and only the last page. Much easier! :-)
>
> It appears to be a type system for reasoning about type safety in generic code without instantiating templates. I guess the most promising possibility is to infer type constraints on parameters directly from the code as well as detecting conflicts (they apparently have discussed something related to this in other papers dealing with "choice types"). But it appears to be a work in progress…

Well just from reading the concept it immediately felt like something that D can use even better. It should be possible to infer concepts implicitly from the template constraints and match those to actual code in template body using proposed calculus. However I am not sure if I am just seeing what I want to see or it is really true.