Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-15 Thread David Nadlinger
On 12/15/10 7:57 PM, Jonathan M Davis wrote: By the way, what does IFTI stand for? Implicit Function Template Instantiation, which allows you to do »void foo(T)(T bar) {}; foo(5);« without manually specifying the template parameter. David

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-15 Thread Jonathan M Davis
On Wednesday, December 15, 2010 05:16:29 Steven Schveighoffer wrote: > On Wed, 15 Dec 2010 04:34:53 -0500, Daniel Murphy > > wrote: > > "Patrick Down" wrote in message > > news:ie8kei$1gd...@digitalmars.com... > > > >> Would it help to allow 'else' and 'else if' on the template constraints? > >

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-15 Thread Steven Schveighoffer
On Wed, 15 Dec 2010 08:16:29 -0500, Steven Schveighoffer wrote: On Wed, 15 Dec 2010 04:34:53 -0500, Daniel Murphy wrote: "Patrick Down" wrote in message news:ie8kei$1gd...@digitalmars.com... Would it help to allow 'else' and 'else if' on the template constraints? void foo(R)(R r) if

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-15 Thread Steven Schveighoffer
On Wed, 15 Dec 2010 04:34:53 -0500, Daniel Murphy wrote: "Patrick Down" wrote in message news:ie8kei$1gd...@digitalmars.com... Would it help to allow 'else' and 'else if' on the template constraints? void foo(R)(R r) if(isRandomAccessRange!R) {...} else if(isInputRange!R) {...} This could

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-15 Thread Daniel Murphy
"Patrick Down" wrote in message news:ie8kei$1gd...@digitalmars.com... > Would it help to allow 'else' and 'else if' on the template constraints? > > void foo(R)(R r) if(isRandomAccessRange!R) > {...} > else if(isInputRange!R) > {...} > > This could basically be translated into two specializations

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-15 Thread spir
On Tue, 14 Dec 2010 13:57:43 -0600 Andrei Alexandrescu wrote: > > Imagine now if I wanted to define a foo that worked only on my specific > > range, I now have to go back and modify the constraints of all the other > > functions. What if I don't have control over that module? > > It scales poo

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Steven Schveighoffer
On Tue, 14 Dec 2010 16:35:49 -0500, Andrei Alexandrescu wrote: On 12/14/10 2:44 PM, Steven Schveighoffer wrote: On Tue, 14 Dec 2010 15:35:30 -0500, Patrick Down wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Would it help to allow 'else' and 'else if' on the t

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Andrei Alexandrescu
On 12/14/10 2:44 PM, Steven Schveighoffer wrote: On Tue, 14 Dec 2010 15:35:30 -0500, Patrick Down wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Would it help to allow 'else' and 'else if' on the template constraints? void foo(R)(R r) if(isRandomAccessRange!R) {...}

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Walter Bright
Steven Schveighoffer wrote: Any idea how this can be 'solved' or do we need to continue doing things like this? My naive instinct is to use the declaration order to determine a match (first one to match wins), but that kind of goes against other overloads in D. Yeah, I'd be extremely relucta

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Steven Schveighoffer
On Tue, 14 Dec 2010 16:03:18 -0500, so wrote: It is exactly your proposal (first one to match wins), with uglier syntax :D Not exactly. It fits within the syntax of D (if-else), and order of evaluation is explicit, whereas one might expect with my original proposal that order does not m

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread so
s/exactly/essentially/

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread so
It is exactly your proposal (first one to match wins), with uglier syntax :D Would it even fulfill your requirements? For example "What if I don't have control over that module?" This one would make it impossible.

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Steven Schveighoffer
On Tue, 14 Dec 2010 15:35:30 -0500, Patrick Down wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Would it help to allow 'else' and 'else if' on the template constraints? void foo(R)(R r) if(isRandomAccessRange!R) {...} else if(isInputRange!R) {...} This could basical

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Patrick Down
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Would it help to allow 'else' and 'else if' on the template constraints? void foo(R)(R r) if(isRandomAccessRange!R) {...} else if(isInputRange!R) {...} This could basically be translated into two specializations like this: void f

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Andrei Alexandrescu
On 12/14/10 1:43 PM, Steven Schveighoffer wrote: On Tue, 14 Dec 2010 13:51:50 -0500, so wrote: Any idea how this can be 'solved' or do we need to continue doing things like this? My naive instinct is to use the declaration order to determine a match (first one to match wins), but that kind of

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Steven Schveighoffer
On Tue, 14 Dec 2010 13:51:50 -0500, so wrote: Any idea how this can be 'solved' or do we need to continue doing things like this? My naive instinct is to use the declaration order to determine a match (first one to match wins), but that kind of goes against other overloads in D. One big

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread so
Any idea how this can be 'solved' or do we need to continue doing things like this? My naive instinct is to use the declaration order to determine a match (first one to match wins), but that kind of goes against other overloads in D. One big plus of current solution is that everything you

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread spir
On Tue, 14 Dec 2010 11:08:04 -0500 "Steven Schveighoffer" wrote: > Having written a few of these functions with template constraints, I > wondered if there was ever any discussion/agreement on reducing verbosity > when specializing template constraints? > > For instance, if you want two over

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Max Samukha
On 12/14/2010 06:09 PM, Andrei Alexandrescu wrote: On 12/14/10 10:08 AM, Steven Schveighoffer wrote: On Tue, 14 Dec 2010 10:47:05 -0500, Andrei Alexandrescu wrote: On 12/14/10 7:33 AM, biozic wrote: I have a question about this and some pieces of code in the standard library, notably std.

Re: Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Andrei Alexandrescu
On 12/14/10 10:08 AM, Steven Schveighoffer wrote: On Tue, 14 Dec 2010 10:47:05 -0500, Andrei Alexandrescu wrote: On 12/14/10 7:33 AM, biozic wrote: I have a question about this and some pieces of code in the standard library, notably std.algorithm: some of the templated functions use templ

Reducing template constraint verbosity? [was Re: Slides from my ACCU Silicon Valley talk]

2010-12-14 Thread Steven Schveighoffer
On Tue, 14 Dec 2010 10:47:05 -0500, Andrei Alexandrescu wrote: On 12/14/10 7:33 AM, biozic wrote: I have a question about this and some pieces of code in the standard library, notably std.algorithm: some of the templated functions use template constraints even when no template overloadin