Re: Differing levels of type-inference: Can D do this?

2012-07-29 Thread Ali Çehreli
On 07/28/2012 01:47 PM, Chad J wrote: What I want to do is constrain that the type of r3 is some kind of range. I don't care what kind of range, it could be a range of integers, a range of floats, an input range, a forward range, and so on. I don't care which, but it has to be a range. It

Re: Differing levels of type-inference: Can D do this?

2012-07-29 Thread Chad J
On 07/29/2012 08:32 AM, Simen Kjaeraas wrote: On Sat, 28 Jul 2012 22:47:01 +0200, Chad J chadjoan@__spam.is.bad__gmail.com wrote: isInputRange!___ r2 = [1,2,3].some.complex.expression(); It doesn't make sense. isInputRange!() isn't a type, so how do I constrain what type is returned from

Re: Differing levels of type-inference: Can D do this?

2012-07-29 Thread Chad J
On 07/29/2012 11:54 AM, Ali Çehreli wrote: On 07/28/2012 01:47 PM, Chad J wrote: What I want to do is constrain that the type of r3 is some kind of range. I don't care what kind of range, it could be a range of integers, a range of floats, an input range, a forward range, and so on. I

Re: Differing levels of type-inference: Can D do this?

2012-07-29 Thread Simen Kjaeraas
On Sun, 29 Jul 2012 19:11:17 +0200, Chad J chadjoan@__spam.is.bad__gmail.com wrote: So there. Now, you simply use auto a = constrain!isInputRange( expression );. Is this what you wanted? That's pretty good. It's still not as concise or easy to discover as the language's natural syntax

Re: Differing levels of type-inference: Can D do this?

2012-07-29 Thread Ali Çehreli
On 07/29/2012 10:22 AM, Chad J wrote: On 07/29/2012 11:54 AM, Ali Çehreli wrote: ForwardRange!int r1 = inputRangeObject(map!2 * a(a1)); ForwardRange!int r2 = inputRangeObject(map!a ^^ 2(a1)); IIRC, these are classes that come with all the typical runtime overhead, right? Yes,

Re: Differing levels of type-inference: Can D do this?

2012-07-28 Thread Jonathan M Davis
On Saturday, July 28, 2012 02:49:16 Chad J wrote: Is there some way to do something similar to this right now? void main() { // Differing levels of type-inference: int[] r1 = [1,2,3]; // No type-inference. That works just fine. Range!(int) r2 = [1,2,3]; // Only range kind

Re: Differing levels of type-inference: Can D do this?

2012-07-28 Thread Ali Çehreli
On 07/27/2012 11:49 PM, Chad J wrote: Range r3 = [1,2,3]; // Element type inferred. If you mean that you wanted a Range!int on the left-hand side, unfortunately there is no template type deduction for struct and class templates. On the other hand, there is type deduction for function

Re: Differing levels of type-inference: Can D do this?

2012-07-28 Thread Chad J
On 07/28/2012 03:03 AM, Jonathan M Davis wrote: On Saturday, July 28, 2012 02:49:16 Chad J wrote: Is there some way to do something similar to this right now? void main() { // Differing levels of type-inference: int[] r1 = [1,2,3]; // No type-inference. That works just fine.

Re: Differing levels of type-inference: Can D do this?

2012-07-28 Thread Jonathan M Davis
On Saturday, July 28, 2012 16:47:01 Chad J wrote: range kind is informal language. Maybe I mean template instances, but that would somewhat miss the point. I don't know how to do this right now. AFAIK, it's not doable. When I speak of ranges I refer specifically to the std.phobos ranges.

Re: Differing levels of type-inference: Can D do this?

2012-07-28 Thread Chad J
On 07/28/2012 04:55 PM, Jonathan M Davis wrote: On Saturday, July 28, 2012 16:47:01 Chad J wrote: range kind is informal language. Maybe I mean template instances, but that would somewhat miss the point. I don't know how to do this right now. AFAIK, it's not doable. When I speak of ranges I

Re: Differing levels of type-inference: Can D do this?

2012-07-28 Thread Chad J
On 07/28/2012 05:55 PM, Jonathan M Davis wrote: On Saturday, July 28, 2012 17:48:21 Chad J wrote: I suppose that works, but it isn't very consistent with how type safety is normally done. Also it's extremely verbose. I'd need a lot of convincing to chose a language that makes me write stuff