Re: Foreach problem

2009-01-12 Thread Bill Baxter
On Tue, Jan 13, 2009 at 6:25 AM, Steven Schveighoffer schvei...@yahoo.com wrote: because that's basically what a foreach does when using opApply: create an inner function and then pass a delegate pointing to that function to opApply. I think the difference between the two is that the

Re: Foreach problem

2009-01-11 Thread Tim M
On Sun, 11 Jan 2009 20:31:51 +1300, Denis Koroskin 2kor...@gmail.com wrote: Yep that probibly is a slight bug. What I would like to know is why cant I do foreach with primitive types like I can with objects. You can use foreach to iterate over arrays and tuples, if that's what you mean.

Foreach problem

2009-01-10 Thread Tim M
Why is this an error. Dmd wants to make sure that I declare a new variable in the foreach statement and not use an existing one? module test; void main() { int i; int[] nums; foreach(i; nums) { // } } dmd test.d test.d(7): Error:

Re: Foreach problem

2009-01-10 Thread Daniel Keep
Tim M wrote: Why is this an error. Dmd wants to make sure that I declare a new variable in the foreach statement and not use an existing one? module test; void main() { int i; int[] nums; foreach(i; nums) { // } } dmd test.d test.d(7): Error: shadowing

Re: Foreach problem

2009-01-10 Thread Tim M
On Sun, 11 Jan 2009 15:50:54 +1300, Daniel Keep daniel.keep.li...@gmail.com wrote: Tim M wrote: Why is this an error. Dmd wants to make sure that I declare a new variable in the foreach statement and not use an existing one? module test; void main() { int i; int[] nums;

Re: Foreach problem

2009-01-10 Thread Tim M
On Sun, 11 Jan 2009 15:59:26 +1300, Tim M a...@b.com wrote: On Sun, 11 Jan 2009 15:50:54 +1300, Daniel Keep daniel.keep.li...@gmail.com wrote: Tim M wrote: Why is this an error. Dmd wants to make sure that I declare a new variable in the foreach statement and not use an existing one?

Re: Foreach problem

2009-01-10 Thread Bill Baxter
On Sun, Jan 11, 2009 at 12:04 PM, Tim M a...@b.com wrote: On Sun, 11 Jan 2009 15:59:26 +1300, Tim M a...@b.com wrote: Why does it still work for some objects? This works: module test; class A { this() { // } } class B { this()

Re: Foreach problem

2009-01-10 Thread Tim M
On Sun, 11 Jan 2009 16:10:39 +1300, Bill Baxter wbax...@gmail.com wrote: On Sun, Jan 11, 2009 at 12:04 PM, Tim M a...@b.com wrote: On Sun, 11 Jan 2009 15:59:26 +1300, Tim M a...@b.com wrote: Why does it still work for some objects? This works: module test; class A { this()

Re: Foreach problem

2009-01-10 Thread Bill Baxter
On Sun, Jan 11, 2009 at 12:15 PM, Tim M a...@b.com wrote: On Sun, 11 Jan 2009 16:10:39 +1300, Bill Baxter wbax...@gmail.com wrote: On Sun, Jan 11, 2009 at 12:04 PM, Tim M a...@b.com wrote: On Sun, 11 Jan 2009 15:59:26 +1300, Tim M a...@b.com wrote: Why does it still work for some objects?

Re: Foreach problem

2009-01-10 Thread Denis Koroskin
On Sun, 11 Jan 2009 06:04:01 +0300, Tim M a...@b.com wrote: On Sun, 11 Jan 2009 15:59:26 +1300, Tim M a...@b.com wrote: On Sun, 11 Jan 2009 15:50:54 +1300, Daniel Keep daniel.keep.li...@gmail.com wrote: Tim M wrote: Why is this an error. Dmd wants to make sure that I declare a new