Re: makeIndex not working

2011-07-02 Thread Johann MacDonagh
On 7/2/2011 10:42 PM, Adam D. Ruppe wrote: Jonathan M Davis wrote: The range has to be mutable. Is there any easy way around this, aside from casting away the outer immutable? It's a very annoying limitation that doesn't really have to be there - I believe the language itself would let you pa

Re: makeIndex not working

2011-07-02 Thread Adam D. Ruppe
Johann MacDonagh wrote: > Just the pointer is passed by value, referencing elements in the > array mutate the source. That's true, but when just moving through a range, the pointer is the only thing that changes. The stuff it points to can still be immutable.

Re: makeIndex not working

2011-07-02 Thread Johann MacDonagh
On 7/2/2011 10:22 PM, Jonathan M Davis wrote: On 2011-07-02 18:14, Johann MacDonagh wrote: On 7/2/2011 9:00 PM, Johann MacDonagh wrote: On 7/2/2011 9:00 PM, bearophile wrote: Johann MacDonagh: I'm confused, what am I doing wrong here? I think that Phobos needs way more&better unittests. I

Re: makeIndex not working

2011-07-02 Thread Johann MacDonagh
On 7/2/2011 10:42 PM, Adam D. Ruppe wrote: Jonathan M Davis wrote: The range has to be mutable. Is there any easy way around this, aside from casting away the outer immutable? It's a very annoying limitation that doesn't really have to be there - I believe the language itself would let you pa

Re: makeIndex not working

2011-07-02 Thread Adam D. Ruppe
Jonathan M Davis wrote: > The range has to be mutable. Is there any easy way around this, aside from casting away the outer immutable? It's a very annoying limitation that doesn't really have to be there - I believe the language itself would let you pass immutable int[] to a regular function that

Re: makeIndex not working

2011-07-02 Thread Jonathan M Davis
On 2011-07-02 18:14, Johann MacDonagh wrote: > On 7/2/2011 9:00 PM, Johann MacDonagh wrote: > > On 7/2/2011 9:00 PM, bearophile wrote: > >> Johann MacDonagh: > >>> I'm confused, what am I doing wrong here? > >> > >> I think that Phobos needs way more&better unittests. > >> > >> I think the error

Re: makeIndex not working

2011-07-02 Thread Johann MacDonagh
On 7/2/2011 9:00 PM, Johann MacDonagh wrote: On 7/2/2011 9:00 PM, bearophile wrote: Johann MacDonagh: I'm confused, what am I doing wrong here? I think that Phobos needs way more&better unittests. I think the error you receive reduces to this: import std.range: isForwardRange; void foo(R)

Re: makeIndex not working

2011-07-02 Thread Johann MacDonagh
On 7/2/2011 9:00 PM, bearophile wrote: Johann MacDonagh: I'm confused, what am I doing wrong here? I think that Phobos needs way more&better unittests. I think the error you receive reduces to this: import std.range: isForwardRange; void foo(R)(R r) if (isForwardRange!R) {} void main() {

Re: makeIndex not working

2011-07-02 Thread bearophile
Johann MacDonagh: > I'm confused, what am I doing wrong here? I think that Phobos needs way more&better unittests. I think the error you receive reduces to this: import std.range: isForwardRange; void foo(R)(R r) if (isForwardRange!R) {} void main() { immutable arr = [1, 2]; foo(arr

makeIndex not working

2011-07-02 Thread Johann MacDonagh
I'm confused, what am I doing wrong here? This example came from the std.algorithm documentation. import std.algorithm; void main() { immutable int[] arr = [ 2, 3, 1, 5, 0 ]; // index using pointers auto index1 = new immutable(int)*[arr.length]; makeIndex!("a < b")(arr, index1); }

Re: Operator Overloading and boilerplate code

2011-07-02 Thread Timon Gehr
Your example with reduced boilerplate code: struct DVECTOR2 { template Accepts(T){enum Accepts=is(T==DVECTOR2) || is(T==float) || is(T==D3DXVECTOR2) || is(T==POINT);} template isScalar(T){enum isScalar=is(T==float);} float x = 0f, y=0f; this()(float x, float y) { this.x = x; this.y = y;

Operator Overloading and boilerplate code

2011-07-02 Thread Loopback
Hi! I've made a two dimensional vector structure (x, y) which is very primitive, the only real thing that I want to do with this structure is support for nearly all operators and support for D3DXVECTOR2 and POINT structures. While writing this structure the boilerplate code has steadily increase