www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Early detection of type errors in templates

reply "bearophile" <bearophileHUGS lycos.com> writes:
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
Sep 14 2014
next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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
Sep 14 2014
prev sibling parent reply "Dicebot" <public dicebot.lv> writes:
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?
Sep 17 2014
parent reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
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…
Sep 17 2014
parent "Dicebot" <public dicebot.lv> writes:
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.
Sep 19 2014