--- Comment #9 from 2011-08-14 18:29:23 PDT ---
(In reply to comment #8)
> Regardless of how good or bad an idea this is, there is no way that this is
> going to change at this point. The current situation is very much by design
> and changing it would break a lot of code.

It's a design that I don't think is the best.

1) [] and null are two ways to do the same thing (empty array literal). Well
designed languages have (try to have) only one obvious way to do something. 

2) When you print an empty array writeln is supposed to write "[]", not null.
Having the code use the same representation produced by writeln is very handy
(example: for code generation, improve debugging output readability, etc).

3) Between [] and null the [] is more specific.

4) DMD needs to break the idea that arrays are pointers. New D programmers need
to be steered as soon as possible away from the idea that D arrays are like C
arrays. While the usage of null to denote empty dynamic arrays reinforces this
wrong idea.

Regarding the current bad D way of mixing the idea of pointers and dynamic
arrays at a visual level, see also issue 3990 that shows this example (it
compiles with DMD 2.054 too):

void main() {
   int[] a1 = [5, 4, 3];
   assert(*a1 == 5);
   alias typeof(a1) T1;
   int* p1 = cast(int*)a1;
   assert(p1 == a1.ptr);

I don't think you will be able to ignore all the things Steven Schveighoffer
says here:

This is not a single change, there are other related changes, see also issue

A tool as Gofix gives a bit more freedom to change:

Regarding "now it's too much late to change it" see also 3843. There are
several more enhancement requests in Bugzilla that as more time passes will
become "now it's too much late to change".

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to