A few questions

Jonathan M Davis jmdavisProg at gmx.com
Fri Jul 27 16:31:58 PDT 2012


On Saturday, July 28, 2012 01:16:41 Namespace wrote:
> Therefore i hope that it will be official added into D.
> Otherwise of course i use it only for projects between me and my
> other students.
> 
> I don't know what is wrong with this shorthand. So why don't give
> it a try?

I don't even know what the last time I dereferenced a null pointer or null  
reference was. It almost never happens to me. I really think that if you're 
seeing very many null dererences, you're doing something fundamentally wrong 
with your code. At minimum, it indicates that you're not unit testing enough, 
since if you do that right, it'll catch the logic errors which give you null 
pointers/references very quickly.

> I'm absolutely sure that Walter will _never_ add real
> non-nullable references.
> All what will maybe come are further structs in std.alghorithm
> which blows up your code as assertions even do.

We will get a NotNull struct at some point (probably in std.typecons). It'll 
statically prevent assignments from null where it can and use assertions where 
it can't. Adding something to the language doesn't buy you much more than that 
anyway. At this point, any new language feature must meet a very high bar, and 
if we can do it in the library instead, we will. D is incredibly powerful and 
is already plenty complex, so we'll take advantage of that power where we can 
rather than trying to change the language further. D arguably has too many 
features as it is.

And as big a deal as you seem to think that this is, the _only_ C-based 
language that I'm aware of which has non-nullable references as part of the 
language is C#. So, while they may have their uses, it's actually very 
uncommon to have them, and since we can add a library type to do it, we can fix 
the problem without altering the language.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list