Re: Early detection of type errors in templates

2014-09-19 Thread Dicebot via Digitalmars-d
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

Re: Early detection of type errors in templates

2014-09-17 Thread via Digitalmars-d
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 t

Re: Early detection of type errors in templates

2014-09-17 Thread Dicebot via Digitalmars-d
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 D

Re: Early detection of type errors in templates

2014-09-14 Thread Andrei Alexandrescu via Digitalmars-d
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

Early detection of type errors in templates

2014-09-14 Thread bearophile via Digitalmars-d
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

Name resolution in templates issue

2013-07-13 Thread JS
I believe this is a flaw in template design, maybe intentional or overlooked or possibly my own lack of knowledge. I have a module with templates in it. I use these templates to built up compile time constructs such as methods, properties, and fields for various things like classes and interfa

Re: detecting classes, structs, arrays in templates

2011-01-23 Thread Luke J. West
Thanks for that bearophile - I'll get myself subscribed right away. Bye for now, Luke On Sun, 23 Jan 2011 09:17:05 -0500, "bearophile" said: > Luke J. West: > > > Hi, > > > > I want to specialize a template function - call it print() - for three > > cases: classes, structs and arrays. Ideally

Re: detecting classes, structs, arrays in templates

2011-01-23 Thread bearophile
Luke J. West: > Hi, > > I want to specialize a template function - call it print() - for three > cases: classes, structs and arrays. Ideally I'd like something that > looks 'functional' like a proper specialization, but perhaps I need to > use "static if". I'm still at the beginning of my journey

Re: detecting classes, structs, arrays in templates

2011-01-23 Thread Simen kjaeraas
Luke J. West wrote: Hi, I want to specialize a template function - call it print() - for three cases: classes, structs and arrays. Ideally I'd like something that looks 'functional' like a proper specialization, but perhaps I need to use "static if". I'm still at the beginning of my journey wi

detecting classes, structs, arrays in templates

2011-01-23 Thread Luke J. West
Hi, I want to specialize a template function - call it print() - for three cases: classes, structs and arrays. Ideally I'd like something that looks 'functional' like a proper specialization, but perhaps I need to use "static if". I'm still at the beginning of my journey with D so I'd be grateful

Re: :? in templates

2009-11-18 Thread Stewart Gordon
Bill Baxter wrote: On Wed, Nov 18, 2009 at 3:16 AM, retard wrote: There's probably a confusion here. It evaluates lazily the value of factorial!(), but its type (which happens to be infinitely recursive must be evaluated eagerly in order to infer the type of the ternary op. That makes sense

Re: :? in templates

2009-11-18 Thread Denis Koroskin
On Wed, 18 Nov 2009 14:50:42 +0300, Bill Baxter wrote: On Wed, Nov 18, 2009 at 3:36 AM, retard wrote: Wed, 18 Nov 2009 03:31:11 -0800, Bill Baxter wrote: On Wed, Nov 18, 2009 at 3:16 AM, retard wrote: Wed, 18 Nov 2009 03:10:57 -0800, Bill Baxter wrote: Didn't this used to work? templat

Re: :? in templates

2009-11-18 Thread Bill Baxter
On Wed, Nov 18, 2009 at 3:36 AM, retard wrote: > Wed, 18 Nov 2009 03:31:11 -0800, Bill Baxter wrote: > >> On Wed, Nov 18, 2009 at 3:16 AM, retard wrote: >>> Wed, 18 Nov 2009 03:10:57 -0800, Bill Baxter wrote: >>> Didn't this used to work? template factorial(int i) {     enum f

Re: :? in templates

2009-11-18 Thread retard
Wed, 18 Nov 2009 03:31:11 -0800, Bill Baxter wrote: > On Wed, Nov 18, 2009 at 3:16 AM, retard wrote: >> Wed, 18 Nov 2009 03:10:57 -0800, Bill Baxter wrote: >> >>> Didn't this used to work? >>> >>> template factorial(int i) { >>>     enum factorial = (i==0) ? 1 : i*factorial!(i-1); >>> } >>> >>> W

Re: :? in templates

2009-11-18 Thread Max Samukha
On Wed, 18 Nov 2009 03:10:57 -0800, Bill Baxter wrote: >Didn't this used to work? > >template factorial(int i) { >enum factorial = (i==0) ? 1 : i*factorial!(i-1); >} > >With DMD 2.036 I'm getting: > Error: template instance factorial!(-495) recursive expansion > >Seems like it expands both b

Re: :? in templates

2009-11-18 Thread Bill Baxter
On Wed, Nov 18, 2009 at 3:16 AM, retard wrote: > Wed, 18 Nov 2009 03:10:57 -0800, Bill Baxter wrote: > >> Didn't this used to work? >> >> template factorial(int i) { >>     enum factorial = (i==0) ? 1 : i*factorial!(i-1); >> } >> >> With DMD 2.036 I'm getting: >>   Error: template instance factori

Re: :? in templates

2009-11-18 Thread retard
Wed, 18 Nov 2009 03:10:57 -0800, Bill Baxter wrote: > Didn't this used to work? > > template factorial(int i) { > enum factorial = (i==0) ? 1 : i*factorial!(i-1); > } > > With DMD 2.036 I'm getting: > Error: template instance factorial!(-495) recursive expansion > > Seems like it expands

:? in templates

2009-11-18 Thread Bill Baxter
Didn't this used to work? template factorial(int i) { enum factorial = (i==0) ? 1 : i*factorial!(i-1); } With DMD 2.036 I'm getting: Error: template instance factorial!(-495) recursive expansion Seems like it expands both branches regardless of the condition. And seems to me like it should