python vs d
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Mon Apr 28 16:02:02 PDT 2014
Nick Sabalausky:
> VB6 let you choose your starting index, too. It was rarely
> useful and constantly made array-handling code a pain in the
> ass. Of course, VB made pretty much everything a PITA...(I used
> to work at a VB6 house. *shudder*)
(As far as I know, and I am ignorant about Julia) in Julia you
can't choose the start index of an array, they start from index
1. So the situation is not the same as VB.
I have written more Delphi code than D code, and I've seen that
being able to choose the index range is quite useful, you can use
enumerations and characters to index arrays :-) You avoid "c -
'0'" the idiom used in D, and associative arrays with enum keys,
while keeping the code very efficient and generally not bug-prone.
I don't know VB much, but all language features should not be
abused. And they work or fail not just being good themselves, but
in the context (and ecology) of all other features of a language.
This means choosing arrays index types and start values is very
good in Ada, it's rarely a PITA. But perhaps a similar feature is
not good if used in VB. Ada has a very strong static typing, so
being able to specify array index types gives you back lot of
safety that probably is not available in VB. So the return of
investment is probably different.
I think it could be a good idea to add something intermediate to
D: optional strong typing for array indexing. I'd like to write a
DIP on this someday (note that this does not mean I am suggesting
D array indexes to optionally start from values different from 0.
I am referring just to types, and enumerations are could be not
supported).
Bye,
bearophile
More information about the Digitalmars-d
mailing list