Bug 18699 – D's builtin arrays could allow a more generic opBinaryAssign with range support

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-03-31T15:06:35Z
Last change time
2024-12-13T18:58:03Z
Assigned to
No Owner
Creator
Seb
Moved to GitHub: dmd#19416 →

Comments

Comment #0 by greensunny12 — 2018-03-31T15:06:35Z
(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; ---
Comment #1 by robert.schadek — 2024-12-13T18:58:03Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19416 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB