C# interview

Anders F Björklund afb at algonet.se
Thu Oct 2 00:48:39 PDT 2008


bearophile wrote:

> This part of the answer shows a future feature of D (note that Delight already has this):
> 
>> 50% of the bugs that people run into today, coding with C# in our
>> platform, and the same is true of Java for that matter, are
>> probably null reference exceptions. If we had had a stronger type
>> system that would allow you to say that 'this parameter may never
>> be null, and you compiler please check that at every call, by doing
>> static analysis of the code'. Then we could have stamped out
>> classes of bugs.

The Delight feature was inspired by Nice, http://nice.sourceforge.net/

"""One documents whether a type can hold the null value by simply 
prefixing it with the ? symbol. Thus: ?String name; is the declaration 
of String variable that might be null. To get its length, one must write 
int len = (name == null) ? 0 : name.length();. Calling name.length() 
directly is a type error. It would only be possible if name was defined 
as String name = "Some non-null string";."""

Other parts are now in main Java, documentation talking about JDK 1.3...

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5030232
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6207924

--anders



More information about the Digitalmars-d mailing list