[Issue 11733] Refuse int indexing of associative arrays with char keys

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 13 04:46:28 PST 2013


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


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor


--- Comment #2 from bearophile_hugs at eml.cc 2013-12-13 04:46:25 PST ---
This is not as important as other changes I have proposed elsewhere.


(In reply to comment #1)
> Why?  0 implicitly converts to both char and dchar.

Because int and char are two different types. It makes code less clear, and in
D there is a simple syntax to express that:

auto r1 = aa1['\0'];
auto r2 = aa2['\0'];

There is no ambiguity here, '\0' is clearly a char for the person that reads
the code. Using 0 instead of '\0' seems a weakly typing archaism coming from C.

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


More information about the Digitalmars-d-bugs mailing list