digitalmars.D.bugs - [Issue 18699] New: D's builtin arrays could allow a more generic
- d-bugmail puremagic.com (36/36) Mar 31 2018 https://issues.dlang.org/show_bug.cgi?id=18699
https://issues.dlang.org/show_bug.cgi?id=18699 Issue ID: 18699 Summary: D's builtin arrays could allow a more generic opBinaryAssign with range support Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: greensunny12 gmail.com (from https://issues.dlang.org/show_bug.cgi?id=13797 where it was proposed to add a new Phobos function for this) tl;dr: appending an array to an array works fine today: --- int[] arr; arr ~= [0, 1, 2]; --- So I don't see any reason why the compiler couldn't be improved to accept this too: --- int[] arr; arr ~= 3.iota; --- Custom data types can already do this with operator overloading, but this is not possible for built-in arrays. The lowering should be trivial as D already allows ranges for `foreach`: --- int[] arr; foreach (e; 3.iota) arr ~= e; --- --
Mar 31 2018