Re: Using inout in delegate

2013-04-02 Thread Jacob Carlborg
On 2013-04-02 16:17, Jacob Carlborg wrote: Then I should probably report this as an issue. http://d.puremagic.com/issues/show_bug.cgi?id=9859 -- /Jacob Carlborg

Re: Using inout in delegate

2013-04-02 Thread Jacob Carlborg
On 2013-04-02 15:03, Kenji Hara wrote: I think this is not a hole of inout design. In this case, the lambda inside foo should capture 'inout' context pointer. void foo (inout int[] arr) { auto dg = { foreach (i, e ; arr) {} }; pragma(msg, typeof(dg)); // should print "v

Re: Using inout in delegate

2013-04-02 Thread Kenji Hara
On Thursday, 28 March 2013 at 14:16:27 UTC, Steven Schveighoffer wrote: On Thu, 28 Mar 2013 04:34:36 -0400, Jacob Carlborg wrote: The following code fails to compile: void foo (inout int[] arr) { auto dg = { foreach (i, e ; arr) {} }; dg(); } void main () { auto a =

Re: Using inout in delegate

2013-04-01 Thread Maxim Fomin
On Monday, 1 April 2013 at 20:37:34 UTC, Kagamin wrote: On Friday, 29 March 2013 at 10:37:42 UTC, Maxim Fomin wrote: You saw one particular example, the problem is much bigger. What's problem? Try it. ??? What to try? It seems there is misunderstanding. I point out that dmd generates name

Re: Using inout in delegate

2013-04-01 Thread Kagamin
On Friday, 29 March 2013 at 10:37:42 UTC, Maxim Fomin wrote: You saw one particular example, the problem is much bigger. What's problem? Try it.

Re: Using inout in delegate

2013-03-29 Thread Maxim Fomin
On Friday, 29 March 2013 at 09:03:11 UTC, Kagamin wrote: On Thursday, 28 March 2013 at 16:34:47 UTC, Maxim Fomin wrote: probably bypassing type system. try to bypass the type system; we just saw the variables are typechecked. You saw one particular example, the problem is much bigger.

Re: Using inout in delegate

2013-03-29 Thread Kagamin
On Thursday, 28 March 2013 at 16:34:47 UTC, Maxim Fomin wrote: probably bypassing type system. try to bypass the type system; we just saw the variables are typechecked.

Re: Using inout in delegate

2013-03-28 Thread Maxim Fomin
On Thursday, 28 March 2013 at 14:16:27 UTC, Steven Schveighoffer wrote: I'm not sure what __aggr1174 is, but you can fix the e error by specifying the type for e (or specifying it as const). -Steve This is a foolishness of dmd frontend. It generates names for copies, temporaries, etc. These

Re: Using inout in delegate

2013-03-28 Thread Jacob Carlborg
On 2013-03-28 15:16, Steven Schveighoffer wrote: Like Timon said, it's a bug in inout design. I'm not sure what __aggr1174 is, but you can fix the e error by specifying the type for e (or specifying it as const). I'm assuming the issue is that the compiler is trying to generate a struct to hol

Re: Using inout in delegate

2013-03-28 Thread Kagamin
well, closure is effectively a struct, so its fields should be properly qualified, e.g. as const.

Re: Using inout in delegate

2013-03-28 Thread Steven Schveighoffer
On Thu, 28 Mar 2013 04:34:36 -0400, Jacob Carlborg wrote: The following code fails to compile: void foo (inout int[] arr) { auto dg = { foreach (i, e ; arr) {} }; dg(); } void main () { auto a = [3, 4, 5]; foo(a); } Error message: main.d(9): Error: variable

Re: Using inout in delegate

2013-03-28 Thread Timon Gehr
On 03/28/2013 09:34 AM, Jacob Carlborg wrote: The following code fails to compile: void foo (inout int[] arr) { auto dg = { foreach (i, e ; arr) {} }; dg(); } void main () { auto a = [3, 4, 5]; foo(a); } Error message: main.d(9): Error: variable main.foo.__la

Using inout in delegate

2013-03-28 Thread Jacob Carlborg
The following code fails to compile: void foo (inout int[] arr) { auto dg = { foreach (i, e ; arr) {} }; dg(); } void main () { auto a = [3, 4, 5]; foo(a); } Error message: main.d(9): Error: variable main.foo.__lambda1.__aggr1174 inout variables can only be declare