Re: Recursive vs. iterative constraints

2016-04-16 Thread Atila Neves via Digitalmars-d
On Saturday, 16 April 2016 at 02:42:55 UTC, Andrei Alexandrescu wrote: So the constraint on chain() is: Ranges.length > 0 && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)) && !is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, Ranges))) == void) Noice. Now, an alternative is to

Re: Recursive vs. iterative constraints

2016-04-16 Thread Daniel N via Digitalmars-d
On Saturday, 16 April 2016 at 09:27:28 UTC, John Colvin wrote: Very strong preference for the first. The second is so much harder to read (not everyone is great at thinking recursively) and also could depend on the implementation of chain if the return type must be inferred from the body.

Re: Recursive vs. iterative constraints

2016-04-16 Thread Andrei Alexandrescu via Digitalmars-d
On 4/15/16 10:58 PM, Alex Parrill wrote:> The only helper function you're getting rid of that I see is allSatisfy, which describes the constraint very well. staticMap, too. -- Andrei

Re: Recursive vs. iterative constraints

2016-04-16 Thread John Colvin via Digitalmars-d
On Saturday, 16 April 2016 at 02:42:55 UTC, Andrei Alexandrescu wrote: So the constraint on chain() is: Ranges.length > 0 && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)) && !is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, Ranges))) == void) Noice. Now, an alternative is to

Re: Recursive vs. iterative constraints

2016-04-16 Thread Daniel N via Digitalmars-d
On Saturday, 16 April 2016 at 03:46:25 UTC, Jonathan M Davis wrote: On Friday, April 15, 2016 22:42:55 Andrei Alexandrescu via Pros? Cons? Preferences? The first one is way cleaner IMHO. - Jonathan M Davis Strong preference for iterative, one key improvement of D's CTFE vs legacy C++

Re: Recursive vs. iterative constraints

2016-04-15 Thread Jonathan M Davis via Digitalmars-d
On Friday, April 15, 2016 22:42:55 Andrei Alexandrescu via Digitalmars-d wrote: > So the constraint on chain() is: > > Ranges.length > 0 && > allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)) && > !is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, Ranges))) == > void) > > Noice. Now,

Re: Recursive vs. iterative constraints

2016-04-15 Thread Alex Parrill via Digitalmars-d
On Saturday, 16 April 2016 at 02:42:55 UTC, Andrei Alexandrescu wrote: So the constraint on chain() is: Ranges.length > 0 && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)) && !is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, Ranges))) == void) Noice. Now, an alternative is to

Recursive vs. iterative constraints

2016-04-15 Thread Andrei Alexandrescu via Digitalmars-d
So the constraint on chain() is: Ranges.length > 0 && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)) && !is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, Ranges))) == void) Noice. Now, an alternative is to express it as a recursive constraint: (Ranges.length == 1 &&