Re: Good project: stride() with constant stride value

2016-03-05 Thread Seb via Digitalmars-d
On Saturday, 5 March 2016 at 13:15:46 UTC, Andrei Alexandrescu wrote: On 03/04/2016 11:34 PM, Jonathan M Davis wrote: This makes me wonder if something like iota would benefit from a similar optimization. Certainly. -- Andrei I haven't done much with CTFE yet, but how would one get the type

Re: Good project: stride() with constant stride value

2016-03-05 Thread kinke via Digitalmars-d
On Friday, 4 March 2016 at 20:14:41 UTC, Andrei Alexandrescu wrote: This is just speculation. When the stride is passed to larger functions the value of the stride is long lost. I understand the desire for nice and simple code but sadly the stdlib is not a good place for it - everything must b

Re: Good project: stride() with constant stride value

2016-03-05 Thread Andrei Alexandrescu via Digitalmars-d
On 03/04/2016 11:34 PM, Jonathan M Davis wrote: This makes me wonder if something like iota would benefit from a similar optimization. Certainly. -- Andrei

Re: Good project: stride() with constant stride value

2016-03-05 Thread Andrei Alexandrescu via Digitalmars-d
On 03/04/2016 09:50 PM, John Colvin wrote: On Friday, 4 March 2016 at 23:33:40 UTC, Andrei Alexandrescu wrote: On 03/04/2016 04:19 PM, H. S. Teoh via Digitalmars-d wrote: Why not rather improve dmd optimization, so that such manual optimizations are no longer necessary? As I mentioned, optimi

Re: Good project: stride() with constant stride value

2016-03-04 Thread Jonathan M Davis via Digitalmars-d
On Friday, 4 March 2016 at 16:45:42 UTC, Andrei Alexandrescu wrote: Currently we have a very useful stride() function that allows spanning a random access range with a specified step, e.g. 0, 3, 6, 9, ... for step 3. I've run some measurements recently and it turns out a compile-time-known st

Re: Good project: stride() with constant stride value

2016-03-04 Thread John Colvin via Digitalmars-d
On Friday, 4 March 2016 at 23:33:40 UTC, Andrei Alexandrescu wrote: On 03/04/2016 04:19 PM, H. S. Teoh via Digitalmars-d wrote: Why not rather improve dmd optimization, so that such manual optimizations are no longer necessary? As I mentioned, optimizing the use of stride in large (non-inline

Re: Good project: stride() with constant stride value

2016-03-04 Thread Andrei Alexandrescu via Digitalmars-d
On 03/04/2016 04:19 PM, Meta wrote: On Friday, 4 March 2016 at 20:14:41 UTC, Andrei Alexandrescu wrote: This is just speculation. When the stride is passed to larger functions the value of the stride is long lost. I understand the desire for nice and simple code but sadly the stdlib is not a go

Re: Good project: stride() with constant stride value

2016-03-04 Thread Andrei Alexandrescu via Digitalmars-d
On 03/04/2016 04:19 PM, H. S. Teoh via Digitalmars-d wrote: Why not rather improve dmd optimization, so that such manual optimizations are no longer necessary? As I mentioned, optimizing the use of stride in large (non-inlined) functions is a tall order. -- Andrei

Re: Good project: stride() with constant stride value

2016-03-04 Thread Andrei Alexandrescu via Digitalmars-d
On 03/04/2016 04:32 PM, Jonathan M Davis wrote: IMHO, it would be cleaner to make them separate templates so that we don't have to give some special meaning to step == 0. And if it made sense for them to share their implementation, we could still have a helper template that did the step == 0 so t

Re: Good project: stride() with constant stride value

2016-03-04 Thread Jonathan M Davis via Digitalmars-d
On Friday, 4 March 2016 at 16:45:42 UTC, Andrei Alexandrescu wrote: Currently we have a very useful stride() function that allows spanning a random access range with a specified step, e.g. 0, 3, 6, 9, ... for step 3. I've run some measurements recently and it turns out a compile-time-known st

Re: Good project: stride() with constant stride value

2016-03-04 Thread H. S. Teoh via Digitalmars-d
On Fri, Mar 04, 2016 at 08:14:41PM +, Andrei Alexandrescu via Digitalmars-d wrote: > kinke wrote: > > On Friday, 4 March 2016 at 17:49:09 UTC, John Colvin wrote: > >> Surely after inlining (I mean real inlining, not dmd) it makes no > >> difference, a constant is a constant? > >> > >> I reme

Re: Good project: stride() with constant stride value

2016-03-04 Thread Meta via Digitalmars-d
On Friday, 4 March 2016 at 20:14:41 UTC, Andrei Alexandrescu wrote: This is just speculation. When the stride is passed to larger functions the value of the stride is long lost. I understand the desire for nice and simple code but sadly the stdlib is not a good place for it - everything must b

Re: Good project: stride() with constant stride value

2016-03-04 Thread Andrei Alexandrescu via Digitalmars-d
kinke wrote: > On Friday, 4 March 2016 at 17:49:09 UTC, John Colvin wrote: >> Surely after inlining (I mean real inlining, not dmd) it makes >> no difference, a constant is a constant? >> >> I remember doing tests of things like that and finding that not >> only did it not make a difference to

Re: Good project: stride() with constant stride value

2016-03-04 Thread jmh530 via Digitalmars-d
On Friday, 4 March 2016 at 18:40:58 UTC, kinke wrote: Then let's not complicate Phobos please. I'm really no friend of special semantics for `step == 0` and stuff like that. Let's keep code as readable and simple as possible, especially in the standard libraries, and let the compilers do thei

Re: Good project: stride() with constant stride value

2016-03-04 Thread kinke via Digitalmars-d
On Friday, 4 March 2016 at 17:49:09 UTC, John Colvin wrote: Surely after inlining (I mean real inlining, not dmd) it makes no difference, a constant is a constant? I remember doing tests of things like that and finding that not only did it not make a difference to performance, ldc produced ne

Re: Good project: stride() with constant stride value

2016-03-04 Thread John Colvin via Digitalmars-d
On Friday, 4 March 2016 at 16:45:42 UTC, Andrei Alexandrescu wrote: Currently we have a very useful stride() function that allows spanning a random access range with a specified step, e.g. 0, 3, 6, 9, ... for step 3. I've run some measurements recently and it turns out a compile-time-known st

Re: Good project: stride() with constant stride value

2016-03-04 Thread Seb via Digitalmars-d
On Friday, 4 March 2016 at 16:45:42 UTC, Andrei Alexandrescu wrote: Currently we have a very useful stride() function that allows spanning a random access range with a specified step, e.g. 0, 3, 6, 9, ... for step 3. I've run some measurements recently and it turns out a compile-time-known st

Good project: stride() with constant stride value

2016-03-04 Thread Andrei Alexandrescu via Digitalmars-d
Currently we have a very useful stride() function that allows spanning a random access range with a specified step, e.g. 0, 3, 6, 9, ... for step 3. I've run some measurements recently and it turns out a compile-time-known stride is a lot faster than a variable. So I was thinking to improve St