digitalmars.D.bugs - foreach and inout
- Valéry Croizier (8/8) Nov 23 2004 Consider :
- Sean Kelly (5/13) Nov 23 2004 This is completely legal from a syntactical perspective--D doesn't have ...
- Regan Heath (7/25) Nov 23 2004 Correct, if however my earlier suggestion that modifying an 'in' variabl...
Consider : class A { int x;} A[10] t; foreach(A a; t) // should be "A inout a" a = new A; Later, an access to any element of 't' is likely to segfault (happened to me :). The compiler should raise an error.
Nov 23 2004
In article <co0cg2$24hq$1 digitaldaemon.com>, Valéry Croizier says...Consider : class A { int x;} A[10] t; foreach(A a; t) // should be "A inout a" a = new A; Later, an access to any element of 't' is likely to segfault (happened to me :). The compiler should raise an error.This is completely legal from a syntactical perspective--D doesn't have any concept of logical const-ness. All you're doing is assigning a new value to a variable. Sean
Nov 23 2004
On Tue, 23 Nov 2004 22:49:06 +0000 (UTC), Sean Kelly <sean f4.ca> wrote:In article <co0cg2$24hq$1 digitaldaemon.com>, Valéry Croizier says...Correct, if however my earlier suggestion that modifying an 'in' variable should be illegal was used this would have given an error. This is the 3rd or 4th instance where the idea would have prevented a bug. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/Consider : class A { int x;} A[10] t; foreach(A a; t) // should be "A inout a" a = new A; Later, an access to any element of 't' is likely to segfault (happened to me :). The compiler should raise an error.This is completely legal from a syntactical perspective--D doesn't have any concept of logical const-ness. All you're doing is assigning a new value to a variable.
Nov 23 2004