Consistency
Steve D via Digitalmars-d
digitalmars-d at puremagic.com
Sun Feb 15 09:18:06 PST 2015
Python (built-in)
dict1 = {"a":1,"b":2}
tup1 = (0,1,2,3)
arr1 = [0,1,2,3] # list type
str1 = "abcd"
print "b" in dict1 # True
print 3 in tup1 # True
print 3 in arr1 # True
print "c" in str1 # True
print tup1.index(2) # 2
print arr1.index(2) # 2
print str1.index("c") # 2
There is some sort of consistency of use, though they are
different sequence/collection types.
Now try the same in D
auto dict1 = ["a":1,"b":2];
auto tup1 = tuple(0,1,2,3);
auto arr1 = [0,1,2,3];
auto str1 = "abcd";
Having some consistency involving
sequences/arrays/strings/collections etc, which are the
foundations of any language makes programming much easier,
intuitive and pleasant. It shouldn't be too difficult for a super
bare-metal language like D.
I'm honestly not knocking D (I love it), just some thoughts
(maybe provoke some discussion?, for D3?)
More information about the Digitalmars-d
mailing list