http://d.puremagic.com/issues/show_bug.cgi?id=3971
--- Comment #26 from [email protected] 2012-02-05 07:25:01 PST --- (In reply to comment #25) > Eventually? Why not now? Before closing this bug, a new issue needs to be written and opened, of course. And I can't want to write a new issue until people give me good answers about what the right behaviors are. See this thread where I have asked questions and shown two alternative proposals: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=149289 I'd like this code to be refused at compile-time: void main() { int[3] a; a = 1; assert(a == [1, 1, 1]); } Just as this is not accepted: void main() { int[] b = new int[3]; b = 1; assert(b == [1, 1, 1]); //Error: cannot implicitly convert expression (1) of type int to int[] } And to be required: void main() { int[3] a; a[] = 1; assert(a == [1, 1, 1]); } I'd like the [] to be required every time an O(n) vector operation is done, for: - constancy with all other vector operations among two arrays, that require []; - and to avoid unwanted (and not easy to spot in the code) O(n) operations; - bugs and confusion in D newbies that don't have memorized all current special cases. But there are other less clear-cut situations. If O(n) vector ops require a [], then this too has to be a compile-time error (despite a and b are values): void main() { int[3] a, b; a = b; // Not OK, hidden vector op } (Struct copies are O(n) operations, but their size if known at compile-time.) While this code is OK: void main() { int[] a = new int[3]; int[] b = new int[3]; a = b; // OK, copies just an array fat reference } Maybe two cases with dynamic arrays are better as compile-time syntax errors to keep more symmetry, I am not sure: void main() { int[] a = new int[3]; int[] b = new int[3]; a[] = b; // error a = b[]; // error } It's not a good idea to open a new bug report before such questions have a good answer because the new bug report risks to quickly become almost as messy as this old one. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
