On Thu, 04 Jul 2013 18:26:09 +0100, Andrei Alexandrescu <seewebsiteforem...@erdani.org> wrote:
Why do you want so much an empty array that's not null? I can't make sense of this entire argument.

Suppose you have a web page, suppose it has a text field on it called "comment". Suppose you load a pre-existing record from your database and populate the page, suppose it had a value for comment, suppose you want to set that comment to be blank. you edit and click save.

The code backing this page is going to get a string for "comment", that string should be empty but not null.

Why? Because if it were null it would have a different meaning. It would mean that the comment field was not present on the page at all, and should not be altered.

There are many such examples. All of them can be worked around by various means but these are all more complex and require additional containers or variables to represent state.

null  - does not exist, was not specified.
empty - exists and was intentionally set to be empty.

I think arrays will be most useful if we can treat them like safe reference types - this wrappers around the unsafe ptr reference type. To do that, we need null/empty to be stable/reliable states.

If not, then array becomes like 'int' and we have to invent a special value to represent the null case (or use other containers/variables to represent null) like we do for int.

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to