[Issue 7227] [] syntax for empty associative array too?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 11 14:15:01 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=7227


Ivan Kazmenko <gassa at mail.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gassa at mail.ru


--- Comment #1 from Ivan Kazmenko <gassa at mail.ru> 2013-03-11 14:14:59 PDT ---
I agree that an empty associative array could use a more convenient syntax.

Consider having an associative array of associative arrays, like in the
following example:

-----
import std.stdio;

void main ()
{
    int [int] [int] f;
    assert (f.length == 0);
    writeln (f); // []
    f[5] = null;
    assert (f.length == 1);
    assert (f[5].length == 0);
    writeln (f); // [5:[]]
}
-----

Now, for a D newbie like me, the line "f[5] = null;" intuitively looks more
like a "delete f[5] from f if it is present" than an "add an empty f[5] into
f".  A syntax like "f[5] = [];" or "f[5] = [:];" would certainly improve
readability here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list