Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread froglegs via Digitalmars-d
I believe Concepts lite in C++ works around this by allowing a syntax like this: void foo(InputRange{T} range1, InputRange{T2} range2) vs. void foo(InputRange range1, InputRange range2) If they are the same type. I believe the objection is that the proposed syntax can't tell the differen

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread H. S. Teoh via Digitalmars-d
On Wed, May 07, 2014 at 08:09:34PM +, w0rp via Digitalmars-d wrote: > On Wednesday, 7 May 2014 at 14:49:17 UTC, Orvid King via Digitalmars-d > wrote: > >On 5/7/14, w0rp via Digitalmars-d wrote: > >>void foo(InputRange range); > > > >How to make it accept multiple types? Simple, we already have

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread w0rp via Digitalmars-d
On Wednesday, 7 May 2014 at 14:49:17 UTC, Orvid King via Digitalmars-d wrote: On 5/7/14, w0rp via Digitalmars-d wrote: void foo(InputRange range); How to make it accept multiple types? Simple, we already have template constraints, so this would be how to do it, where T is the element type

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread Nordlöw
Ahh, it seems this syntax is currently accepted by DMD. Should it be? Correction: Ahh, it seems this syntax is currently *not* accepted by DMD. Should it be?

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread John Colvin via Digitalmars-d
On Wednesday, 7 May 2014 at 16:04:39 UTC, Nordlöw wrote: void foo(T)(InputRange!T range); Update: Ahh, it seems this syntax is currently accepted by DMD. Should it be? Original function: import std.range: isInputRange; bool allEqual(R)(R range) @safe pure nothrow if (isInputRange!R) {

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread Nordlöw
void foo(T)(InputRange!T range); Update: Ahh, it seems this syntax is currently accepted by DMD. Should it be? Original function: import std.range: isInputRange; bool allEqual(R)(R range) @safe pure nothrow if (isInputRange!R) { import std.algorithm: findAdjacent; import std.range

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread Nordlöw
void foo(T)(InputRange!T range); Clever. Shouldn't we all, including Phobos, use this shorter syntax instead? Further, we could always do alias R = InputRange!T; or alias R = typeof(range); inside the body if needed.

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread Orvid King via Digitalmars-d
On 5/7/14, w0rp via Digitalmars-d wrote: > void foo(InputRange range); How to make it accept multiple types? Simple, we already have template constraints, so this would be how to do it, where T is the element type of the input range: void foo(T)(InputRange!T range);

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread w0rp via Digitalmars-d
On Wednesday, 7 May 2014 at 12:47:29 UTC, Sergei Nosov wrote: void foo(InputRange range1, InputRange range2); // how to specify that InputRange should be exactly the same type? or possibly distinct types? One thing to consider would be that InputRange wouldn't be a type itself, but range1 and

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread bearophile via Digitalmars-d
Sergei Nosov: void foo(InputRange range1, InputRange range2); // how to specify that InputRange should be exactly the same type? or possibly distinct types? I think the Concepts lite proposal faces this problem too. Take a look. But so far Andrei was against the idea of having lite concept

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread Mason McGill via Digitalmars-d
On Wednesday, 7 May 2014 at 11:57:51 UTC, w0rp wrote: Here is a question, is it possible for D, or any future language, to eventually take something like this... void foo(InputRange)(InputRange range) if(isInputRange!InputRange); ...and to instead be able to write it like this? void foo(Inp

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread Sergei Nosov via Digitalmars-d
On Wednesday, 7 May 2014 at 11:57:51 UTC, w0rp wrote: Here is a question, is it possible for D, or any future language, to eventually take something like this... void foo(InputRange)(InputRange range) if(isInputRange!InputRange); ...and to instead be able to write it like this? void foo(Inp

Re: A Briefer Syntax for Using Concepts

2014-05-07 Thread John Colvin via Digitalmars-d
On Wednesday, 7 May 2014 at 11:57:51 UTC, w0rp wrote: Here is a question, is it possible for D, or any future language, to eventually take something like this... void foo(InputRange)(InputRange range) if(isInputRange!InputRange); ...and to instead be able to write it like this? void foo(Inp

A Briefer Syntax for Using Concepts

2014-05-07 Thread w0rp via Digitalmars-d
Here is a question, is it possible for D, or any future language, to eventually take something like this... void foo(InputRange)(InputRange range) if(isInputRange!InputRange); ...and to instead be able to write it like this? void foo(InputRange range); Where the latter expands into somethin