Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Sergey Gromov
Fri, 12 Dec 2008 15:24:39 -0500, Zoran Isailovski wrote: > Denis Koroskin Wrote: > On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski wrote: > I'm an experienced C#, Java and Python programmer, and have employed > closures (and C# delegates) upon numerous occasions. Wh

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread BCS
Reply to Zoran, I don't think it is restrictive if the compiler prevented a situation that would otherwise lead to a run-time error anyway, or worse, weird and confusing run-time behavior. In my case, if the compiler couldn't SAFELY handle a reference to the argument n outside the enclosing func

Re: Why is my code does not compile? (dmd 2.021 linux)

2008-12-12 Thread Weed
Bill Baxter пишет: Ref return values are a very new feature in D2. I suspect its just a bug that they don't work on inner functions yet. --bb message implies that the authors are aware of this limitation? report they do not need? No, a report is probably needed. There are lots of bugs with

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread BCS
Reply to Zoran, Thx, Denis, but I'm still confused. The stack thing was also my first thought. But when I tried to actually explain the dynamics that way, I came to the conclusion that then, test1() shouldn't have worked either. what might be happening is that test1 is not using up enough st

Re: Why is my code does not compile? (dmd 2.021 linux)

2008-12-12 Thread Bill Baxter
2008/12/13 Weed : > Bill Baxter пишет: >> >> On Sat, Dec 13, 2008 at 5:45 AM, Weed wrote: >>> >>> void main() >>> { >>> int i; >>> >>> ref int func() >>> { >>> return i; >>> } >>> >>> func() = 4; >>> } >>> >>> lval.d(5): found 'ref' instead of statement >>> lval.d(10): no identifier

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Jérôme M. Berger
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Zoran Isailovski wrote: > I'm an experienced C#, Java and Python programmer, and have employed closures > (and C# delegates) upon numerous occasions. While experimenting with D > closures and delegates, I was stroke by a phenomenon I cannot explain.

Re: Why is my code does not compile? (dmd 2.021 linux)

2008-12-12 Thread Weed
Bill Baxter пишет: On Sat, Dec 13, 2008 at 5:45 AM, Weed wrote: void main() { int i; ref int func() { return i; } func() = 4; } lval.d(5): found 'ref' instead of statement lval.d(10): no identifier for declarator func lval.d(11): unrecognized declaration but code like t

Re: Why is my code does not compile? (dmd 2.021 linux)

2008-12-12 Thread Bill Baxter
On Sat, Dec 13, 2008 at 5:45 AM, Weed wrote: > > void main() > { >int i; > >ref int func() >{ > return i; >} > >func() = 4; > } > > lval.d(5): found 'ref' instead of statement > lval.d(10): no identifier for declarator func > lval.d(11): unrecognized declaration > > > but

Why is my code does not compile? (dmd 2.021 linux)

2008-12-12 Thread Weed
void main() { int i; ref int func() { return i; } func() = 4; } lval.d(5): found 'ref' instead of statement lval.d(10): no identifier for declarator func lval.d(11): unrecognized declaration but code like this compiles: ref int func() { int* i = new int; return

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Zoran Isailovski
Denis Koroskin Wrote: > On Fri, 12 Dec 2008 22:28:01 +0300, Zoran Isailovski > wrote: > > > Denis Koroskin Wrote: > > > >> On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski > >> wrote: > >> > >> > I'm an experienced C#, Java and Python programmer, and have employed > >> > closures (and C#

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Zoran Isailovski
Denis Koroskin Wrote: > On Fri, 12 Dec 2008 22:18:28 +0300, Zoran Isailovski > wrote: > > > Denis Koroskin Wrote: > > > >> On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski > >> wrote: > >> > >> > I'm an experienced C#, Java and Python programmer, and have employed > >> > closures (and C#

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Denis Koroskin
On Fri, 12 Dec 2008 22:28:01 +0300, Zoran Isailovski wrote: Denis Koroskin Wrote: On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski wrote: > I'm an experienced C#, Java and Python programmer, and have employed > closures (and C# delegates) upon numerous occasions. While experimenting

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Zoran Isailovski
Denis Koroskin Wrote: > On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski > wrote: > > > I'm an experienced C#, Java and Python programmer, and have employed > > closures (and C# delegates) upon numerous occasions. While experimenting > > with D closures and delegates, I was stroke by a

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Denis Koroskin
On Fri, 12 Dec 2008 22:18:28 +0300, Zoran Isailovski wrote: Denis Koroskin Wrote: On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski wrote: > I'm an experienced C#, Java and Python programmer, and have employed > closures (and C# delegates) upon numerous occasions. While experimenting

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Zoran Isailovski
Frits van Bommel Wrote: > Zoran Isailovski wrote: > > I'm an experienced C#, Java and Python programmer, and have employed > > closures (and C# delegates) upon numerous occasions. While experimenting > > with D closures and delegates, I was stroke by a phenomenon I cannot > > explain. Here's th

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Zoran Isailovski
Denis Koroskin Wrote: > On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski > wrote: > > > I'm an experienced C#, Java and Python programmer, and have employed > > closures (and C# delegates) upon numerous occasions. While experimenting > > with D closures and delegates, I was stroke by a

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Frits van Bommel
Zoran Isailovski wrote: I'm an experienced C#, Java and Python programmer, and have employed closures (and C# delegates) upon numerous occasions. While experimenting with D closures and delegates, I was stroke by a phenomenon I cannot explain. Here's the code: [snip] Handler incBy(int n) {

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Denis Koroskin
On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski wrote: I'm an experienced C#, Java and Python programmer, and have employed closures (and C# delegates) upon numerous occasions. While experimenting with D closures and delegates, I was stroke by a phenomenon I cannot explain. Here's t

confusing (buggy?) closure behaviour

2008-12-12 Thread Zoran Isailovski
I'm an experienced C#, Java and Python programmer, and have employed closures (and C# delegates) upon numerous occasions. While experimenting with D closures and delegates, I was stroke by a phenomenon I cannot explain. Here's the code: module closures01; import std.stdio; alias int delegate(i

Re: -nan problem???

2008-12-12 Thread Sheridan
Hi! I have created a sample code to show my "-nan" problem. It is not the cleanest code :-), but I do not want to delete a lot from the problematic files. I realized, that the problem appears only when the compiler "Optimize" flag is enabled. I use Derelict and Codeblocks. You can also downloa