https://d.puremagic.com/issues/show_bug.cgi?id=12139

           Summary: AA.update
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2014-02-12 04:26:13 PST ---
This is a possible enhancement. I don't know how much useful it is, but it
seems worth thinking about.

One recent change in the Erlang language is the syntax to handle associative
arrays:

> Updating a map is done as follows:
> 
> NewX = X#{ key1 => Val1, ... KeyN := ValN, ...}

X is the old associative array. "=>" adds a new key, while ":=" updates an
already existing key, and if it's not present an error is generated. So a
spelling mistake cannot accidentally introduce a new key if you just want to
update some value. This avoids a common bug.

Similarly a simple "AA.update(key, val)" function in the D object module could
be useful. It's a way to modify associative array values that requires the keys
to be already present. This function modifies the value of a key-value if the
key is present, and raises an exception if the key is missing.

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

Reply via email to