Re: foreach, tupleof

2010-03-08 Thread Philippe Sigaud
On Mon, Mar 8, 2010 at 22:11, bearophile wrote: > Philippe Sigaud: > > assert(c = ); // is there a literal for char.init? '' doesn't > > work. > > I think it's '\xFF' but I don't know if it may change in future, so using > char.init is probably better, more readable, more explicit in its purpose

Re: foreach, tupleof

2010-03-08 Thread bearophile
Philippe Sigaud: > assert(c = ); // is there a literal for char.init? '' doesn't > work. I think it's '\xFF' but I don't know if it may change in future, so using char.init is probably better, more readable, more explicit in its purpose, and less prone to typing bugs. Bye, bearophile

Re: foreach, tupleof

2010-03-08 Thread Philippe Sigaud
On Sun, Mar 7, 2010 at 19:53, Ellery Newcomer wrote: > On 03/07/2010 12:23 PM, Jacob Carlborg wrote: > >> It's a bug: http://d.puremagic.com/issues/show_bug.cgi?id=2411 >> You can use the following code as a workaround: >> >> foreach (i, dummy ; s.tupleof) >> s.tupleof[i] = 1; >> > > Totally aweso

Re: foreach, tupleof

2010-03-07 Thread Ellery Newcomer
On 03/07/2010 12:23 PM, Jacob Carlborg wrote: On 3/7/10 19:11, Ellery Newcomer wrote: Hello. In D1, this code fails: void foo(S)(ref S s){ foreach(ref k; s.tupleof){ k = 1; } } struct K{ int g; } void main(){ K k; foo(k); assert(k.g == 1); } test.d(5): Error: no storage class for value k

Re: foreach, tupleof

2010-03-07 Thread Jacob Carlborg
On 3/7/10 19:11, Ellery Newcomer wrote: Hello. In D1, this code fails: void foo(S)(ref S s){ foreach(ref k; s.tupleof){ k = 1; } } struct K{ int g; } void main(){ K k; foo(k); assert(k.g == 1); } test.d(5): Error: no storage class for value k (referring to 'k = 1;') Is this an expected er

foreach, tupleof

2010-03-07 Thread Ellery Newcomer
Hello. In D1, this code fails: void foo(S)(ref S s){ foreach(ref k; s.tupleof){ k = 1; } } struct K{ int g; } void main(){ K k; foo(k); assert(k.g == 1); } test.d(5): Error: no storage class for value k (referring to 'k = 1;') Is this an expected error, and is there a good