[Issue 10535] [AA] Add a function to druntime which returns an empty AA

2022-07-27 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10535

Nick Treleaven  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Nick Treleaven  ---
dlang/dmd pull request #14257 "Make `new AA` allocate the associative array
Impl" was merged into master:

- e8cdd13a92487ad6ef206a9ca2e8c030a6c56e68 by Nick Treleaven:
  Fix 2 fail_compilation tests

https://github.com/dlang/dmd/pull/14257

--


[Issue 10535] [AA] Add a function to druntime which returns an empty AA

2021-11-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10535

Nick Treleaven  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=7227

--


[Issue 10535] [AA] Add a function to druntime which returns an empty AA

2019-03-02 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10535

Nick Treleaven  changed:

   What|Removed |Added

 CC||ket...@ketmar.no-ip.org

--- Comment #6 from Nick Treleaven  ---
*** Issue 16269 has been marked as a duplicate of this issue. ***

--


[Issue 10535] [AA] Add a function to druntime which returns an empty AA

2019-03-02 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10535

Dlang Bot  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #5 from Dlang Bot  ---
@ntrel created dlang/druntime pull request #2504 "Fix Issue 10535 - Add
initialize function to allocate an empty AA" fixing this issue:

- Fix Issue 10535 - Add AA initialize function

https://github.com/dlang/druntime/pull/2504

--


[Issue 10535] [AA] Add a function to druntime which returns an empty AA

2019-02-27 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10535

Nick Treleaven  changed:

   What|Removed |Added

 CC||n...@geany.org
   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=16269

--- Comment #4 from Nick Treleaven  ---
(In reply to Daniel Kozak from comment #3)
> auto aa = new VT[KT]();

This would be good (although I don't think the () parens serve a purpose). `new
AA` is natural syntax for allocating an empty AA, unlike []. Having `new` in
the syntax is a great reminder to the programmer that they're allocating memory
even though the AA is empty.

V[K][6] sixAAs = new V[K];
V[K][6] sixAAs = [];

The `new` version above may remind the programmer that each AA reference will
point to the same empty heap AA. The `[]` version looks like initializing each
AA reference to an empty AA, which isn't clear that the AA references all point
to the same memory. In this case the programmer may well have intended each AA
reference to point to a unique empty heap AA, so that inserting an element in
one isn't reflected into every AA reference.

(In reply to monarchdodra from comment #1)
> There might be a better "generic" solution to the "empty initialization"
> (eg: "arg-less-constructor") problem.

For user-defined reference types, the solution is the zero-arg class
constructor, `new Container`. That mirrors the `new V[K]` syntax.

--


[Issue 10535] [AA] Add a function to druntime which returns an empty AA

2014-08-06 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10535

Daniel Kozak kozz...@gmail.com changed:

   What|Removed |Added

 CC||kozz...@gmail.com

--- Comment #3 from Daniel Kozak kozz...@gmail.com ---
What about allow this:
auto aa = new VT[KT]();

or

VT[KT] aa = [];

http://forum.dlang.org/thread/oikhlzndptghonqko...@forum.dlang.org#post-sfcppaolmnhxfjvrekkm:40forum.dlang.org

--