Re: "IndexType" for ranges

2012-10-02 Thread Nick Sabalausky
On Tue, 02 Oct 2012 19:23:48 +0200 "Jonathan M Davis" wrote: > On Tuesday, October 02, 2012 19:10:53 monarch_dodra wrote: > > Ideally, only size_t would be allowed. Reality makes it so that we > need ulong in some cases (e.g. iota). Given that fact, you'd ideally > restrict it to size_t or ulong

Re: "IndexType" for ranges

2012-10-02 Thread Jonathan M Davis
On Tuesday, October 02, 2012 20:45:36 David Nadlinger wrote: > On Tuesday, 2 October 2012 at 17:24:32 UTC, Andrei Alexandrescu > > wrote: > > Yes. Unfortunately there are few, few cases in which size_t is > > insufficient (e.g. an input range from a file or a large iota, > > both on 32-bit builds)

Re: "IndexType" for ranges

2012-10-02 Thread Peter Alexander
On Tuesday, 2 October 2012 at 18:45:24 UTC, David Nadlinger wrote: On Tuesday, 2 October 2012 at 17:24:32 UTC, Andrei Alexandrescu wrote: Yes. Unfortunately there are few, few cases in which size_t is insufficient (e.g. an input range from a file or a large iota, both on 32-bit builds). I perso

Re: "IndexType" for ranges

2012-10-02 Thread David Nadlinger
On Tuesday, 2 October 2012 at 17:24:32 UTC, Andrei Alexandrescu wrote: Yes. Unfortunately there are few, few cases in which size_t is insufficient (e.g. an input range from a file or a large iota, both on 32-bit builds). I personally think these are too few to need formal support. I'd throw b

Re: "IndexType" for ranges

2012-10-02 Thread Jonathan M Davis
On Tuesday, October 02, 2012 19:37:18 monarch_dodra wrote: > On Tuesday, 2 October 2012 at 17:07:19 UTC, monarch_dodra wrote: > > [SNIP] > > You know what, I think I have a better. Idea. All of this came up > because I've had iota break my compiles WAY more often then I'd > have liked. But I think

Re: "IndexType" for ranges

2012-10-02 Thread monarch_dodra
On Tuesday, 2 October 2012 at 17:07:19 UTC, monarch_dodra wrote: [SNIP] You know what, I think I have a better. Idea. All of this came up because I've had iota break my compiles WAY more often then I'd have liked. But I think I know of another solution. I think it would be nice if we enforc

Re: "IndexType" for ranges

2012-10-02 Thread Jonathan M Davis
On Tuesday, October 02, 2012 19:08:59 Piotr Szturmaj wrote: > Jonathan M Davis wrote: > > if length can be specifically ulong and the type is random access, then > > its > > indices will need to be ulong), so unfortunately, the situation is not so > > simple that you can always assume size_t (even

Re: "IndexType" for ranges

2012-10-02 Thread Andrei Alexandrescu
On 10/2/12 1:07 PM, monarch_dodra wrote: I don't know, forcing an implementer on size_t is pretty gratuitous. Why can't he be free to choose his own index type? Too much freedom can be detrimental (as is in this case). Andrei

Re: "IndexType" for ranges

2012-10-02 Thread monarch_dodra
On Tuesday, 2 October 2012 at 17:13:48 UTC, Jonathan M Davis wrote: On Tuesday, October 02, 2012 15:17:58 monarch_dodra wrote: You might think "just use typeof(length)" BUT: *you aren't even guaranteed that "typeof(length)" will be correct! Certain ranges, such as iota, will return a length usua

Re: "IndexType" for ranges

2012-10-02 Thread Andrei Alexandrescu
On 10/2/12 12:45 PM, Peter Alexander wrote: On Tuesday, 2 October 2012 at 16:29:28 UTC, Simen Kjaeraas wrote: On 2012-10-02, 18:09, Peter Alexander wrote: On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra wrote: If you've ever worked on a template that needs to index a range, you may

Re: "IndexType" for ranges

2012-10-02 Thread Jonathan M Davis
On Tuesday, October 02, 2012 19:10:53 monarch_dodra wrote: > Given your stance of "I see _zero_ reason to support lengths or > indices smaller than size_t" and "Types that do that are badly > designed IMHO": > > Are you agreeing with my proposed type tightening? If anything, > it weeds out the "ba

Re: "IndexType" for ranges

2012-10-02 Thread monarch_dodra
On Tuesday, 2 October 2012 at 16:59:38 UTC, Jonathan M Davis wrote: On Tuesday, October 02, 2012 18:45:50 Peter Alexander wrote: On Tuesday, 2 October 2012 at 16:29:28 UTC, Simen Kjaeraas wrote: > On 2012-10-02, 18:09, Peter Alexander wrote: >> On Tuesday, 2 October 2012 at 13:17:45 UTC, monarc

Re: "IndexType" for ranges

2012-10-02 Thread Jonathan M Davis
On Tuesday, October 02, 2012 15:17:58 monarch_dodra wrote: > You might think "just use typeof(length)" BUT: > *you aren't even guaranteed that "typeof(length)" will be > correct! Certain ranges, such as iota, will return a length > usually of type uint, but be indexed with ulong... :/ > *Infinite r

Re: "IndexType" for ranges

2012-10-02 Thread Piotr Szturmaj
Jonathan M Davis wrote: if length can be specifically ulong and the type is random access, then its indices will need to be ulong), so unfortunately, the situation is not so simple that you can always assume size_t (even you should arguably be able to). It seems that isRandomAccessRange doesn't

Re: "IndexType" for ranges

2012-10-02 Thread monarch_dodra
On Tuesday, 2 October 2012 at 16:48:34 UTC, Peter Alexander wrote: Then don't create ranges that use ushort for indexing and length. There's no need to. To be clear, I'm suggesting that all random access ranges should use size_t, and they will not be random access ranges if they use anything

Re: "IndexType" for ranges

2012-10-02 Thread Jonathan M Davis
On Tuesday, October 02, 2012 18:45:50 Peter Alexander wrote: > On Tuesday, 2 October 2012 at 16:29:28 UTC, Simen Kjaeraas wrote: > > On 2012-10-02, 18:09, Peter Alexander wrote: > >> On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra > >> > >> wrote: > >>> If you've ever worked on a templat

Re: "IndexType" for ranges

2012-10-02 Thread Piotr Szturmaj
monarch_dodra wrote: On Tuesday, 2 October 2012 at 16:09:16 UTC, Peter Alexander wrote: On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra wrote: If you've ever worked on a template that needs to index a range, you may have run into this problem: What is the type you should use to index

Re: "IndexType" for ranges

2012-10-02 Thread monarch_dodra
On Tuesday, 2 October 2012 at 16:44:48 UTC, monarch_dodra wrote: On Tuesday, 2 October 2012 at 16:09:16 UTC, Peter Alexander wrote: On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra wrote: If you've ever worked on a template that needs to index a range, you may have run into this proble

Re: "IndexType" for ranges

2012-10-02 Thread Peter Alexander
On Tuesday, 2 October 2012 at 16:44:48 UTC, monarch_dodra wrote: On Tuesday, 2 October 2012 at 16:09:16 UTC, Peter Alexander wrote: On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra wrote: If you've ever worked on a template that needs to index a range, you may have run into this proble

Re: "IndexType" for ranges

2012-10-02 Thread Peter Alexander
On Tuesday, 2 October 2012 at 16:29:28 UTC, Simen Kjaeraas wrote: On 2012-10-02, 18:09, Peter Alexander wrote: On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra wrote: If you've ever worked on a template that needs to index a range, you may have run into this problem: What is the type

Re: "IndexType" for ranges

2012-10-02 Thread monarch_dodra
On Tuesday, 2 October 2012 at 16:09:16 UTC, Peter Alexander wrote: On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra wrote: If you've ever worked on a template that needs to index a range, you may have run into this problem: What is the type you should use to index an RA range? Forgiv

Re: "IndexType" for ranges

2012-10-02 Thread Simen Kjaeraas
On 2012-10-02, 18:09, Peter Alexander wrote: On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra wrote: If you've ever worked on a template that needs to index a range, you may have run into this problem: What is the type you should use to index an RA range? Forgive my ignorance. Wha

Re: "IndexType" for ranges

2012-10-02 Thread Peter Alexander
On Tuesday, 2 October 2012 at 13:17:45 UTC, monarch_dodra wrote: If you've ever worked on a template that needs to index a range, you may have run into this problem: What is the type you should use to index an RA range? Forgive my ignorance. What's wrong with size_t?

"IndexType" for ranges

2012-10-02 Thread monarch_dodra
If you've ever worked on a template that needs to index a range, you may have run into this problem: What is the type you should use to index an RA range? The problem may not sound like much, but it is a royal pain in the ass when trying to write "wrapper ranges", such as std.algorithm.map.