<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx</link><description>Many people were intrigued at Tech-Ed when Anders revealed the deep language integration we were giving to the new System.Nullable&amp;lt;A&amp;gt; type. I could go more in depth into how it works, but for now I'll just to briefly explain it. Nullable&amp;lt;A&amp;gt;</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147792</link><pubDate>Thu, 03 Jun 2004 17:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147792</guid><dc:creator>Nick Schweitzer</dc:creator><description>A programmer after my own heart.&lt;br&gt;&lt;br&gt;My orininal thought would be to just allow for an implicit conversion of a nullable type to bool for purposes of if checking... see here&lt;br&gt;&lt;a target="_new" href="http://schweitn.blogspot.com/2004/04/my-syntactic-sweet-tooth.html"&gt;http://schweitn.blogspot.com/2004/04/my-syntactic-sweet-tooth.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;But now that I've read this... I think that non-nullable types would rock.  It would almost be like going back to the days of user defined class instances being allocated on the stack... sometimes I miss the C++ days.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147793</link><pubDate>Thu, 03 Jun 2004 17:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147793</guid><dc:creator>anon</dc:creator><description>Isn't that feature in Cw (C-omega) ?&lt;br&gt;&lt;a target="_new" href="http://research.microsoft.com/collaboration/university/europe/Events/AcademicDays/UK-IE/2004/ClaudioRussao-Comega.ppt"&gt;http://research.microsoft.com/collaboration/university/europe/Events/AcademicDays/UK-IE/2004/ClaudioRussao-Comega.ppt&lt;/a&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147802</link><pubDate>Thu, 03 Jun 2004 17:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147802</guid><dc:creator>damien morton</dc:creator><description>im with you - nullable should go hand in hand with non-nullable.&lt;br&gt;&lt;br&gt;in fact, non-nullable types have behavior that is a strict subset of normal variables, and so introducing them should be a problem-free excersise.&lt;br&gt;&lt;br&gt;nullable types are a superset of the behaviour of normal types, and changing a normal variable to a nullable variable can potentially cause problems.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147815</link><pubDate>Thu, 03 Jun 2004 18:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147815</guid><dc:creator>Giampiero</dc:creator><description>I think the usefullness of something like this is questionable. For example, what happens when you set a string! to the return value of a function that returns string and that value is null sometimes. There is no compile time check for that, so you still have to check that value in your code (unless you want ArgumentNullExceptions) everywhere and the usefullness is lost. So from re-usability standpoint this idea works great. I grab an API and it declares object! to be one of the parameters so I know I cannot pass a null value. This means that anything that I get from an outside method would have to be checked by me before I could pass it into this API method. But then that doesn't really help the consumer of the API, does it?</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147823</link><pubDate>Thu, 03 Jun 2004 18:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147823</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Nick:  The C++ days... *shudder* :-)</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147825</link><pubDate>Thu, 03 Jun 2004 18:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147825</guid><dc:creator>Fredrik Normén NSQUARED2</dc:creator><description>I like it :)&lt;br&gt;&lt;br&gt;Something that I would like to have in C# is const, but I could live with A!&lt;br&gt;&lt;br&gt;Another thing that I would like to see in the framework is an INullable interface, just the one in the System.Datra.SqlTypes byt I would like to have it inte ht System namespace. There is a INullable today, but it's internal and used by Nullable&amp;lt;T&amp;gt;. The reason why I want to have a INullable interface with an IsNull property, is that I could then create nullable object, for example NullCustomer. Martin Fowler wrote about Null objects in his refactoring book, and I have used it in my solutions and it's very useful.&lt;br&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147829</link><pubDate>Thu, 03 Jun 2004 18:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147829</guid><dc:creator>Brian Schkerke</dc:creator><description>As someone who works with databases and financial software - where 0 and null are two different beasts entirely - I cannot wait for my pain to end.&lt;br&gt;&lt;br&gt;I'm currently using types I created because the SqlTypes weren't serializable.  (And Cyrus, if you have any pull at all, would you ask SOMEONE there why all the base types are sealed?  Please?  Argh..)&lt;br&gt;&lt;br&gt;Here's waiting anxiously.&lt;br&gt;&lt;br&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147830</link><pubDate>Thu, 03 Jun 2004 18:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147830</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Giampero: you would not be allowed to set a string! to a function that returns a string.  You would have to explictly check for null in that case (by using something like the ! operator i talked about above).  It could look something like this:&lt;br&gt;&lt;br&gt;string! str = !! methodThatReturnsAPotentiallyNullValuedString()&lt;br&gt;&lt;br&gt;That would become a runtime check.  If you got an isntance back it would be ok, if you got a null value back it would throw. Similar to how casting can throw today at runtime.&lt;br&gt;&lt;br&gt;The benefit is within your own code, and if the APIs are used you will, in general have less checking to do than today.  (Note: today you'd currently have to check that that return type was not null as well).</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147836</link><pubDate>Thu, 03 Jun 2004 18:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147836</guid><dc:creator>AT</dc:creator><description>1. What will be an Exception error message for this test case ?&lt;br&gt;&lt;br&gt;A a = null;&lt;br&gt;A! na = !A;  // &amp;lt;-- ??&lt;br&gt;&lt;br&gt;Will it be meanless System.NullPointerException ?? &lt;br&gt;How do you expect user to be able decrypt this message and fix origin if his boss asking him to complete report in 10 minutes ;o) ??&lt;br&gt;&lt;br&gt;I expect more user-friendly exceptions given to user if you are unable to avoid them.&lt;br&gt;&lt;br&gt;2. Also I do not see big benefits for this. &lt;br&gt;It's about that same that Java users have to do with    (MyObject) Collection.get(i) without actually knowledge of data inside collection. &lt;br&gt;The only benefit is early null error detection if value is not used immediately. But I always check values before storing them anythere. This ! operator will be simply a shortcut for this. &lt;br&gt;MSFT can possibly implement it without changing CLR at compiler level as Microsoft Extension ;o)&lt;br&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147843</link><pubDate>Thu, 03 Jun 2004 18:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147843</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Giampero, as the consumer of that API you have to do that check anyways, because if you don't the API will throw an NullReferenceException (or ArgumentNullException) when you pass in the null value.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147845</link><pubDate>Thu, 03 Jun 2004 18:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147845</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Brian: I'll look into it and see if there's someone who can answer your question for you.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147851</link><pubDate>Thu, 03 Jun 2004 18:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147851</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>AT: what is the use of the exception you get in the:&lt;br&gt;&lt;br&gt;&amp;quot;string a = (string)o;&amp;quot; case?&lt;br&gt;&lt;br&gt;ClassCastException.  Not very helpful.  But you can use it plus  astack trace ot figure out what's going wrong and fixing it.&lt;br&gt;&lt;br&gt;The help you get is similar to generics.  By having this syntax you remove the need to place an:&lt;br&gt;&lt;br&gt;if (object.ReferenceEquals(null, someArgument)) {&lt;br&gt;    throw new ArgumentNullException(&amp;quot;someArgument&amp;quot;);&lt;br&gt;}&lt;br&gt;&lt;br&gt;at every single entrypoint in your code.  Not only that, but you need to make sure your documentation reflects that that's what will happen.&lt;br&gt;&lt;br&gt;Having that directly in the signature means that you don't have to do that check _ever_.  THe consumer also knows now that there will be a problem passing null.&lt;br&gt;&lt;br&gt;Imagine the following case.  v1 of an API takes a string and allows it to be null (the api says it's undefined what will happen with a null argument).  v2 no longer allows it to be null and throws in that case.  You call that API only extremely rarely with a null value and you expect it to work as before.  However, now you get some random crash in a critical service that you have to track down and fix.  With strong support in the runtime/bcl/language, you instead have a compile time check that will tell you flat out: this argument can not, under any cirsumstances, take a null value.  You must perform that check yourself.&lt;br&gt;&lt;br&gt;By doing that check yourself you protect against unknown exceptions getting thrown to you at runtime that would cause you to crash.&lt;br&gt;&lt;br&gt;I think the !! operator would just give you a NullReferenceException.  If you want better messages then just type out:&lt;br&gt;&lt;br&gt;if (object.ReferenceEquals(foo, null)) {&lt;br&gt;   throw new SpecializedException(&amp;quot;very wrong bad!&amp;quot;);&lt;br&gt;}</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147895</link><pubDate>Thu, 03 Jun 2004 19:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147895</guid><dc:creator>Kael Rowan</dc:creator><description>Definitely!  In my personal ideal world, C# would have originally had support for nullable types and then all types/arguments *not* defined as nullable would be non-nullable by default.  In other words, even reference types would always have to be set to an instance of an object unless they are declared as nullable (string?, ArrayList?, even object?).  &lt;br&gt;&lt;br&gt;In the vast majority of cases, APIs always require instances of objects as arguments and rarely do they accept null references.  Not only would I (and my development peers) LOVE to have non-nullable types, we would love to have an option to compile ALL types as non-nullable unless specified otherwise (such as string?, ArrayList?, or even object?).  I would gladly change my signatures to void foo(object? nullableObj) when a null reference is acceptable if it would save me hundreds of lines of if (nullableObj == null) throw new ArgumentNullException(&amp;quot;...&amp;quot;);&lt;br&gt;&lt;br&gt;To the person(s) above who feel that having exceptions thrown when null references are set to a non-nullable type (i.e. string! myStr = null;), I say you would have check for null manually and ended up throwing a ArgumentNullException or NullReferenceException yourself, or if you didn't do the check then you'd get a NullReferenceException when you tried to access the null reference (i.e. myStr.Length).  If your problem was calling an API that was changed to accept a non-nullable argument then you would have gotten an ArgumentNullException after passing null to the API anyway.&lt;br&gt;&lt;br&gt;Having compile-time checking for the possibility of null being set to non-nullable types would be great and prevent tons of runtime errors, but even without compile-time checking the check could be automatically put in place at runtime which would save developers significant development time and increase robustness by taking the burden of null checks off of the developer.&lt;br&gt;&lt;br&gt;-Kael&lt;br&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147896</link><pubDate>Thu, 03 Jun 2004 19:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147896</guid><dc:creator>Phil Weber</dc:creator><description>Hi, Cyrus: Luke Hutteman (of SharpReader fame) proposed this very idea yesterday: &lt;a target="_new" href="http://www.hutteman.com/weblog/2004/06/02-181.html"&gt;http://www.hutteman.com/weblog/2004/06/02-181.html&lt;/a&gt; &lt;br&gt;&lt;br&gt;+1 from me!</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147922</link><pubDate>Thu, 03 Jun 2004 20:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147922</guid><dc:creator>Omer van Kloeten</dc:creator><description>Cyrus,&lt;br&gt;&lt;br&gt;I think this is a nice feature, but I can not see its usefulness. I have never encountered a time when I needed to keep something from being null.&lt;br&gt;&lt;br&gt;Why pass the argument through the method in your post? Mostly because you're unsure of what you get, since you would get it from the user in some way or something. All in all, an untrusted call.&lt;br&gt;&lt;br&gt;This just takes the responsibility for the value not to be null and places it in the caller's hands. It forces the caller to use the non-nullable type. It's also harder to trace the exception if you don't have the PDB.&lt;br&gt;&lt;br&gt;You talk about the versioning case when V1 allows null and V2 doesn't. This would cause a throw when sending null. This is where side-by-side execution goes into play. You will always use the V1 assembly.&lt;br&gt;Switching to V2, haven't read the docs and haven't got a unit testing case causing null calls to this in your code?&lt;br&gt;tsk tsk tsk.&lt;br&gt;&lt;br&gt;Again, it's nice syntactic sugar, but then again, too much sugar is bad for your teeth. ;)</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147935</link><pubDate>Thu, 03 Jun 2004 20:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147935</guid><dc:creator>Giampiero</dc:creator><description>Ok, I got it now. Took me a while (and a few rebuttle examples that didn't pan out)to realize where the benefit is.&lt;br&gt;&lt;br&gt;But one more thing is, what happens to the BCL APIs that don't use this construct (which there are a lot of)? If you don't change the APIs, what is the point in having this? If you do change the APIs you break backwards compatibility because everyone would need to use that new operator.&lt;br&gt;&lt;br&gt;Basically it just seems to me that is making things easier on the API writer's end and harder on the consumers end (more casts). A language convenience like this could be nice but really doesn't let you do something that you couldn't do before (unlike Nullable&amp;lt;T&amp;gt;). &amp;lt;Opinion&amp;gt;Seems like more work than the gain.&amp;lt;/Opinion&amp;gt;&lt;br&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147938</link><pubDate>Thu, 03 Jun 2004 20:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147938</guid><dc:creator>David Larsson</dc:creator><description>Synchronisity... I had this exact discussion today about the usefulness of non-nullable types that complement nullable types. I want it!  &lt;br&gt;There are issues, of course... A non-null type could not be a member of a struct, since it must have a constructor that sets all members to their default values (null for ref types). A non-null class member would have to be initialized in the constructor of the class, but how would one guarantee that the member isn't accessed (indirectly, via some other method called from the constructor) before the class has finished constructing? So, it seems that you wouldn't be able to guarantee with 100% certainty, even if your program is verifiably type safe, that an instance of a non-null type is never null, but I still think this is a useful feature. </description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147961</link><pubDate>Thu, 03 Jun 2004 21:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147961</guid><dc:creator>Hallgrim</dc:creator><description>I do too, I do too!&lt;br&gt;&lt;br&gt;Non-nulls force types to define their behaviour when their value is unknown, instead of letting every one assume what the behaviour is. &lt;br&gt;&lt;br&gt;A good example is numbers. Instead checking for null:&lt;br&gt;   if (number != null &amp;amp;&amp;amp; number &amp;lt; maximum) ...&lt;br&gt;The behaviour for a &amp;quot;null number&amp;quot; is defined in for instance NaN. It will always return false for tests, so the example becomes:&lt;br&gt;   if (number &amp;lt; maximum) ...</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147964</link><pubDate>Thu, 03 Jun 2004 21:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147964</guid><dc:creator>Orion Adrian</dc:creator><description>One confusion I'm seeing is that cardinality is being confused with reference versus value (i.e. heap allocated versus stack allocated). They aren't actually the same thing, but by default a cardinality of 0 or 1 is associated with reference variables and a cardinality of exactly 1 is associated with value types. They don't have to be and in my opinion they shouldn't be.&lt;br&gt;&lt;br&gt;IMO, by default all objects should have cardinality 0 or 1 (!). So string should be the same as string! and int should be the same as int!.&lt;br&gt;&lt;br&gt;As a programmer, I shouldn't really care how variables are stored (i.e. stack versus heap). That's really the compiler's problem. But I always care about the structure of my data (i.e. its types and those variable's cardinalities).&lt;br&gt;&lt;br&gt;Orion Adrian</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147968</link><pubDate>Thu, 03 Jun 2004 21:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147968</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Omer: Interesting.  Almost every single API i write can not deal with null inputs.  This affects me in 3 ways.  I must:&lt;br&gt;a) check for null and throw in my methods&lt;br&gt;b) keep my docs up to date to tell consumers of this problem&lt;br&gt;c) fix crashes that occur because i forgot to check if a value was non null before sending it into the library.&lt;br&gt;&lt;br&gt;With the new system i just write:&lt;br&gt;&lt;br&gt;foo(string! string) and i get:&lt;br&gt;a) No need to check for null&lt;br&gt;b) No need to keep docs up to date.  The signature is the doc&lt;br&gt;c) No need to fix NullReference or ArgumentNull crashes&lt;br&gt;&lt;br&gt;As the consumer of the api i no longer need to:&lt;br&gt;a) Read the docs to know what set of values are allowed&lt;br&gt;&lt;br&gt;I do however have to:&lt;br&gt;a) Check my values ot make sure they're not null before I send them to the API.  However, this is not new, I had to do this before.  Now I'm just forced to do the safe thing rather then finding out weeks from now tht i was doing something wrong when an exception gets thrown.&lt;br&gt;&lt;br&gt;Compile time safety is a very very good thing IMO.  I'd rather have static type checking then runtime failures any day :-)</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147970</link><pubDate>Thu, 03 Jun 2004 21:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147970</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Orion: Could you explain a little bit more about what it means for an object ot have cardinality?  I think i understand, but i'd appreciate more information.&lt;br&gt;&lt;br&gt;Also, why should things, by default, be allowed to be valueless.  It seems safer and more clear to make them valued by default and to only explicitly make them valueless if the need arises.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147979</link><pubDate>Thu, 03 Jun 2004 21:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147979</guid><dc:creator>AT</dc:creator><description>Cyrus: &lt;br&gt;I feel that changing in a way you proposed for current C# stage will complicate things must more that it benefit users. &lt;br&gt;&lt;br&gt;If you have problems to check input params - this can because you use wrong code to do this. All params validation inside methods can be a one-line call to helper class implementing Bouncer pattern (see &lt;a target="_new" href="http://c2.com/cgi/wiki?BouncerPattern"&gt;http://c2.com/cgi/wiki?BouncerPattern&lt;/a&gt; or &lt;a target="_new" href="http://24.odessa.ua/java/Validation.java"&gt;http://24.odessa.ua/java/Validation.java&lt;/a&gt; as example)&lt;br&gt;&lt;br&gt;Something like :&lt;br&gt;public boolean doFoo(Object param1, Method param2, Object[] args) throws NullPointerException {        &lt;br&gt;Validation.checkNotNull(param1,&amp;quot;param1&amp;quot;);&lt;br&gt;Validation.checkNotNull(param2,&amp;quot;param2&amp;quot;);&lt;br&gt;&lt;br&gt;Also you are reducing problem too much. There is a lot of other checks that must be performed for params passed. &lt;br&gt;a) String must be not empty or  s.trim() not empty&lt;br&gt;b) Array must be non-empty&lt;br&gt;c) All values in array must pass validation - like a non-null or like a)&lt;br&gt;d) Values for two (or more) params must be non-conflicting - like min&amp;lt;=max or each value in [min,max] range&lt;br&gt;etc .. &lt;br&gt;&lt;br&gt;You will be unable to solve all of this problems at compiler level. &lt;br&gt;But introducing Validation class will unify exceptions raised across entire project.&lt;br&gt;&lt;br&gt;&lt;br&gt;Possibly some rules for FxCop or any other source analyzer can allow to diagnose several kinds of errors easily.&lt;br&gt;If you worry too much about performance - you are living currently in 2004 and if you really need this - you can check all params only in debug builds.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147985</link><pubDate>Thu, 03 Jun 2004 21:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147985</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>AT: Excellent points.  BTW this has _nothing_ to do with performance.  Also, see in my message how I implemented that pattern.&lt;br&gt;&lt;br&gt;Note though.  With the current model both the API consumer and producer must agree on this contract and ensure that it is maintained.  Of course, this is no different from any other API contract, however, in this case it is such a common occurrance (literally hundreds of calls and methods i must document about this single issue) that the saving to both consumer and producer woudl be great (IMO).&lt;br&gt;&lt;br&gt;Also, why would you limit Types in that way?  People wanted nullable structs because they foudn structs too limiting not being able to be null.  Why not allow symmetry in teh type system?  Nullable/Non-nullable versions of every type?</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147988</link><pubDate>Thu, 03 Jun 2004 21:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147988</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>AT: I like your idea of a single unified location to verify arguments.  That's what my 'Argument' class is intended to provide.&lt;br&gt;&lt;br&gt;I see this more as a completeness argument (and maybe i should have pitched it that way) with the added benefit that you get strong compile time safety against a common class of problems.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147989</link><pubDate>Thu, 03 Jun 2004 21:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147989</guid><dc:creator>damien morton</dc:creator><description>AT: you are right that non-null declarations cant possibly completely validate paramaters, but consider this: what is one of the most commonly encountered exceptions in java and C# - its the null pointer exception thown at runtime.&lt;br&gt;&lt;br&gt;By having verifyable declarations on method paramaters and return values; your Validation.NonNull() methods only need to be inserted when a method is called with potentially non-null values.&lt;br&gt;&lt;br&gt;I know from my experience that the C# codebases I work on tend to grow null checks in far too many places. Being able to declare a method as not accepting potentially null arguments will mitigate that null-check growth, and allow the compiler to do the work for you.&lt;br&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147994</link><pubDate>Thu, 03 Jun 2004 21:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147994</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Anecdotally, the number of bugs/crashes i've had to deal with as a programmer due to dereferences null has been enormous.  In fact it's almost always an issue of:&lt;br&gt;&lt;br&gt;a) multi-threading woes&lt;br&gt;b) memory fudging (problems with allocating/freeing)&lt;br&gt;c) simple simple logic errors concerning null's&lt;br&gt;&lt;br&gt;The amount of time that something is actually a complex issue that is difficult to weed out is far rarer and less time consuming than just dealing with these issues.  Any system that can remove that issue from me at compile time is a big win in my book.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147995</link><pubDate>Thu, 03 Jun 2004 21:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147995</guid><dc:creator>damien morton</dc:creator><description>Cyrus:&lt;br&gt;&lt;br&gt;You could even have the compiler infer when variables can never be null:&lt;br&gt;&lt;br&gt;i.e. the following code should compile and run just fine.&lt;br&gt;&lt;br&gt;string! foo(string s)&lt;br&gt;{&lt;br&gt;   if (s == null)&lt;br&gt;     return &amp;quot;&amp;quot;;&lt;br&gt;   else&lt;br&gt;     return s;&lt;br&gt;}&lt;br&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#147997</link><pubDate>Thu, 03 Jun 2004 21:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147997</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>AT: Another point, while I wrote the validation code, I don't like it.  There's already duplication in it that I want to refactor.  Namely the passing of the argument and the name.  It's small, but it is a smell and it's more book keeping for me to keep track of.  The internal call also won't update my XML docs, nor will it make my callers verify that their values are not null before passing them in.   All in all we've pushed the issue to failing at runtime which always has the chance of getting missed. :(</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148015</link><pubDate>Thu, 03 Jun 2004 22:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148015</guid><dc:creator>AT</dc:creator><description>Simply a list of related links:&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://research.microsoft.com/~maf/Papers/non-null.pdf"&gt;http://research.microsoft.com/~maf/Papers/non-null.pdf&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://cdsmith.twu.net/professional/java/pontifications/nonnull.html"&gt;http://cdsmith.twu.net/professional/java/pontifications/nonnull.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Or more generic problem:&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://archive.eiffel.com/doc/manuals/technology/contract/"&gt;http://archive.eiffel.com/doc/manuals/technology/contract/&lt;/a&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148020</link><pubDate>Thu, 03 Jun 2004 22:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148020</guid><dc:creator>Orion Adrian</dc:creator><description>Cardinaility is the number of objects in a set. Every variable you have is essentially a set (not a mathematical set). Basically every variable has a minumum number of values and a maximum number of values it can contain.&lt;br&gt;&lt;br&gt;Value variables in C# must be there (minimum cardinality of 1 and maximum cardinality of 1 often written (1,1) or !)&lt;br&gt;&lt;br&gt;Reference variables in C# may be there ( (0,1) or ? ) .&lt;br&gt;&lt;br&gt;Arrays in C# have cardinality of (0,*) or * which means 0 or more. The double use of * is often confusing, but they mean two different things. The first * means many (or more than 1) and the second star is short for a cardinality of (0,*). Though the maximum cardinality of an array (as opposed to an ArrayList) can be specified to be some number N.&lt;br&gt;&lt;br&gt;string[12] has a cardinality of (0,12) in that it can contain anywhere between 0 and 12 values.&lt;br&gt;&lt;br&gt;Now a simplification can be made in langauge (some already have this) and allow any variable to have arbitrary cardinality. For example:&lt;br&gt;&lt;br&gt;string[2,12] would be an array of strings that can have between 2 and 12 values. Anything else would be an error.&lt;br&gt;&lt;br&gt;One nicety about this particular technique is that arrays and non-arrays merge. There's only one set of concepts. For instance what's the difference between an empty array and a null array. Not much (there should be none). The compiler should take care of the initialization on first use.&lt;br&gt;&lt;br&gt;So if an object is null, it's Empty. If an array has 0 elements it's also Empty. The test becomes the same. Even if we just limit ourselves to (?,!,*,+) we still come out ahead.&lt;br&gt;&lt;br&gt;I've blogged about this and included a few comments on casting. Hopefully it will make a little more sense. If it doesn't just drop me a line at: oadrian@at@hotmail.com . Remove the extra characters.&lt;br&gt;&lt;br&gt;Orion Adrian</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148024</link><pubDate>Thu, 03 Jun 2004 22:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148024</guid><dc:creator>Steve Perry</dc:creator><description>My only problem with nulls comes down to displaying values (on a form or on the web). How many times do I have to write (sorry for the VB code).&lt;br&gt;If not isnull(databaseField) then&lt;br&gt;  textbox1.text=format(databaseField,&amp;quot;C&amp;quot;)&lt;br&gt;Else&lt;br&gt;  textbox1.text=&amp;quot;$0.00&amp;quot;&lt;br&gt;End If&lt;br&gt;&lt;br&gt;What I want to write is &lt;br&gt;textbox1.text=format(ifnull(databaseField,&amp;quot;0&amp;quot;),&amp;quot;C&amp;quot;)&lt;br&gt;&lt;br&gt;Basicly if databaseField is null return &amp;quot;0&amp;quot; otherwise return databaseField&lt;br&gt;&lt;br&gt;FIX THIS PLEASE!!!</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148030</link><pubDate>Thu, 03 Jun 2004 22:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148030</guid><dc:creator>AT</dc:creator><description>Steve: There is built-in function in VB for Access  - Nz(checkValue,valueIfNull). You can create example of own or use built-in if such exists.&lt;br&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148036</link><pubDate>Thu, 03 Jun 2004 22:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148036</guid><dc:creator>Orion Adrian</dc:creator><description>&amp;quot;My only problem with nulls comes down to displaying values (on a form or on the web). How many times do I have to write (sorry for the VB code).&lt;br&gt;If not isnull(databaseField) then&lt;br&gt;textbox1.text=format(databaseField,&amp;quot;C&amp;quot;)&lt;br&gt;Else&lt;br&gt;textbox1.text=&amp;quot;$0.00&amp;quot;&lt;br&gt;End If&lt;br&gt;&lt;br&gt;What I want to write is&lt;br&gt;textbox1.text=format(ifnull(databaseField,&amp;quot;0&amp;quot;),&amp;quot;C&amp;quot;) &amp;quot;&lt;br&gt;&lt;br&gt;The problem I see with this is why the field is null in the first place. This seems more a problem to do with the constraints  (or lack of) placed on the data and less a problem to do with displaying it. $0.00 and null are not the same. This isn't something I'd like to see even if it was simple to implement.&lt;br&gt;&lt;br&gt;Ask this question, &amp;quot;Why is databaseField null and not 0, and if it's null why would I want to display it as 0?&amp;quot;&lt;br&gt;&lt;br&gt;Orion Adrian</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148044</link><pubDate>Thu, 03 Jun 2004 23:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148044</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Steve: C# also has support for this through the Null-Coalescing operator ??.  It works in the following manner:&lt;br&gt;&lt;br&gt;expr = expression1 ?? expression2&lt;br&gt;&lt;br&gt;if expression1 evaluates to a non-null value then it is the value of 'expr'.  If expression1 evaluates to a null value the expression2 is the value of 'expr'.  So in C# you could write:&lt;br&gt;&lt;br&gt;textbox1.text = format(databaseField, &amp;quot;C&amp;quot;) ?? &amp;quot;$0.00&amp;quot;;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148045</link><pubDate>Thu, 03 Jun 2004 23:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148045</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Orion: Because there's a difference between your view and the underlying representation behing the scenes.  It would be just as reasonable to have:&lt;br&gt;&lt;br&gt;textbox1.text = format(databaseField, &amp;quot;C&amp;quot;) ?? &amp;quot;Squashed Cockroach&amp;quot;; &lt;br&gt;&lt;br&gt;However, it's important for the underlying data to have the ability to say &amp;quot;this does not have a cost&amp;quot; as opposed to &amp;quot;this cost is nothing&amp;quot;.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148049</link><pubDate>Thu, 03 Jun 2004 23:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148049</guid><dc:creator>Orion Adrian</dc:creator><description>&amp;quot;textbox1.text = format(databaseField, &amp;quot;C&amp;quot;) ?? &amp;quot;Squashed Cockroach&amp;quot;;&lt;br&gt;&lt;br&gt;However, it's important for the underlying data to have the ability to say &amp;quot;this does not have a cost&amp;quot; as opposed to &amp;quot;this cost is nothing&amp;quot;.&amp;quot;&lt;br&gt;&lt;br&gt;This I agree with. I guess I should have been more clear. I just wanted to express that in the specific example the problem wasn't in the formatting, it was in the data structure. However how to display null is always a problem. That and whether to display it at all.&lt;br&gt;&lt;br&gt;Orion Adrian</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148053</link><pubDate>Thu, 03 Jun 2004 23:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148053</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Orion: Fascinating information about the cardinality of things.  I've never thought of variables as sets before, but having that consistancy would be great across the entire language.&lt;br&gt;&lt;br&gt;Also, thanks much for the articles.  I'll see what i can do about spreading that information around in here so we can consider it for future langauge improvements.&lt;br&gt;&lt;br&gt;Knowing how much people care about these things goes a long way in deciding what we'll be doing in the future.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148063</link><pubDate>Thu, 03 Jun 2004 23:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148063</guid><dc:creator>Steve Perry</dc:creator><description>My point was not to say there is no difference between $0.00 and NULL. My point was that there is not easy way (in VB.net, guess there is in C#) to convert this null value into something that I can display to the user (ie. N/A or $0.00 or &amp;quot;VALUE NOT SET&amp;quot; or what ever is required.) &lt;br&gt;&lt;br&gt;By the way I wrote my own function which emulates foxpro NVL to do this but it requires 5 overloaded functions (boolean, date, integer, string, decimal)  I would rather have it built in.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148163</link><pubDate>Fri, 04 Jun 2004 05:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148163</guid><dc:creator>Neil Conway</dc:creator><description>This is nit-picking, but a &amp;quot;null&amp;quot; value in C# does not really model the NULL concept in a (standards conformant) SQL RDBMS. Per the SQL standard,&lt;br&gt;&lt;br&gt;NULL = NULL evaluates to NULL (_not_ &amp;quot;true&amp;quot;)&lt;br&gt;NULL = x evaluates to NULL for all x (even if there are values of x that happen to be NULL)&lt;br&gt;NULL &amp;lt;&amp;gt; NULL also evaluates to NULL (not &amp;quot;false&amp;quot;)&lt;br&gt;&lt;br&gt;You get the point. The justification is that NULL means &amp;quot;unknown value&amp;quot;, so it isn't known whether two unknown values are equal to one another.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148178</link><pubDate>Fri, 04 Jun 2004 05:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148178</guid><dc:creator>Neil Conway</dc:creator><description>Ah, ok -- Cyrus has beaten me with the clue stick offline, so I now _really_ understand how Nulllable in C# is going to work. So ignore the previous post :-)&lt;br&gt;&lt;br&gt;(That said, it seems to me that overloading the &amp;quot;null&amp;quot; literal to mean both &amp;quot;unknown&amp;quot; and &amp;quot;all-zero-pointer&amp;quot; is asking for confusion...)</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148273</link><pubDate>Fri, 04 Jun 2004 08:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148273</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Neil: I've got my own reservations about this issue :-)&lt;br&gt;&lt;br&gt;That said, i think the readers might appreciate an example where this could be quite confusing given our current understanding of how null works in C# now.  Would you like to show that?</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148305</link><pubDate>Fri, 04 Jun 2004 10:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148305</guid><dc:creator>RichB</dc:creator><description>Please please please implement A!. Scratch nullable types, A! is 10 times more useful.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148524</link><pubDate>Fri, 04 Jun 2004 15:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148524</guid><dc:creator>Nicole Calinoiu</dc:creator><description>I'm with AT on this one.  Non-nullable types would be lovely, and I'd certainly use them.  However, assuming that you operate under finite time and resources like the rest of us, I'd much rather see implementation of a well-integrated, declarative pre-condition framework before/instead of non-nullable types.&lt;br&gt;&lt;br&gt;From a purely personal point of view, null values are actually the simplest of my validation hurdles. I validate early, often, and very thoroughly, and I cannot think of a single case in which I would accept a non-null value that should not be subjected to further restrictions.  However, implementing all this is currently quite a bit of work.  The effort involved could be dramatically reduced, particularly wrt communicating the rules to consumers and verifying that validation has actually been applied, if an appropriate pre-condition framework were in place.&lt;br&gt;&lt;br&gt;So that's anal retentive, paranoid me.  What about normal people? &amp;lt;g&amp;gt;  You mentioned in your comment #147989 that null reference exceptions are one of the most common classes of exceptions.  This wouldn't surprise me in the least--far too many folks barely validate at all so, of course, they're having problems with unexpected nulls.  Even for strict validators, it's just too easy to miss a validation point, so these will creep in despite our best intentions.&lt;br&gt;&lt;br&gt;That said, at least a null reference exception has a reasonable chance of being caught in dev or test.  Even if the problem does make it into production, it'll probably be relatively easy to trace and fix _before_ the damage runs too deep.  Failure to apply other types of restrictions can be much more difficult to find and fix, and the chances are much greater that they will have security implications.  (Please note that the two previous sentences are meant to represent sweeping generalizations.  I'm well aware that there are glaring exceptions on both sides of the fence. &amp;lt;g&amp;gt;)&lt;br&gt;&lt;br&gt;All in all, I'd expect that there are many more problems (some of which will never show up as exceptions) in production code today due to failure to properly validate non-nulls than there are null reference problems.  It's difficult to group the former because they can manifest in so many ways, but the balance shouldn't necessarily be weighted toward the latter just because they're more obvious or easier to count.&lt;br&gt;&lt;br&gt;Adding a pre-condition framework would help address both classes of validation, even if it doesn't go quite so far wrt enforcing non-null values.  Adding non-nullable types would only address one problem, and might even hurt wrt the other since it could potentially increase the chances that folks forget about applying any validation at all.  Of course, adding both would be fantastic!</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148595</link><pubDate>Fri, 04 Jun 2004 16:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148595</guid><dc:creator>Isaac Gouy</dc:creator><description>Cyrus, &amp;lt;b&amp;gt;you can experience the joys of non-nullable types&amp;lt;/b&amp;gt; and write code for JVM and use Java libraries.&lt;br&gt;&lt;br&gt;In the &amp;lt;a href=&amp;quot;&lt;a target="_new" href="http://nice.sourceforge.net/manual.html#optionTypes&amp;quot;&amp;gt;Nice"&gt;http://nice.sourceforge.net/manual.html#optionTypes&amp;quot;&amp;gt;Nice&lt;/a&gt; language&amp;lt;/a&amp;gt; standard types &amp;lt;i&amp;gt;are&amp;lt;/i&amp;gt; non-nullable. If we want to allow null values then we must declare an option type (String is non-nullable; ?String is nullable).&lt;br&gt;&lt;br&gt;&amp;lt;pre&amp;gt;&lt;br&gt;void main(String[] args){  &lt;br&gt;   ?String someNull = null;&lt;br&gt;   ?String someString = &amp;quot;Some String&amp;quot;;&lt;br&gt;   println( foo(someNull) );&lt;br&gt;   println( foo(someString) );&lt;br&gt;}&lt;br&gt;&lt;br&gt;String foo(?String s){ &lt;br&gt;   if (s != null) &lt;br&gt;      return s;&lt;br&gt;   else &lt;br&gt;      return &amp;quot;Some Null&amp;quot;;&lt;br&gt;} &lt;br&gt;&lt;br&gt;// output&lt;br&gt;Test&amp;gt;java -jar test.jar&lt;br&gt;Some Null&lt;br&gt;Some String&lt;br&gt;&amp;lt;/pre&amp;gt;&lt;br&gt;&lt;br&gt;Of course, there are compile time checks:&lt;br&gt;&amp;lt;pre&amp;gt;&lt;br&gt;String foo(?String s){ &lt;br&gt;   if (s != null) &lt;br&gt;      return s;&lt;br&gt;   else &lt;br&gt;      return s; &lt;br&gt;} &lt;br&gt;&lt;br&gt;// output&lt;br&gt;&amp;gt;nicec --sourcepath .. -a t.jar test&lt;br&gt;nice.lang: parsing&lt;br&gt;test: parsing&lt;br&gt;test: typechecking&lt;br&gt;&lt;br&gt;test.nice: line 12, column 7:&lt;br&gt;s might be null&lt;br&gt;&amp;lt;/pre&amp;gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148766</link><pubDate>Fri, 04 Jun 2004 20:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148766</guid><dc:creator>AT</dc:creator><description>Isaac, Nicole  - Microsoft already implemented  FxCop-like validator at IL level fully compatible with current CLR runtime using attributes. &lt;br&gt;&lt;br&gt;See &lt;a target="_new" href="http://research.microsoft.com/~maf/Papers/non-null.pdf"&gt;http://research.microsoft.com/~maf/Papers/non-null.pdf&lt;/a&gt;&lt;br&gt;&lt;br&gt;I hope they will be able to put it in production from research fast.&lt;br&gt;&lt;br&gt;Note - in addition to simply null-checking they was able to reveal a lot of others problems. </description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#148827</link><pubDate>Fri, 04 Jun 2004 21:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148827</guid><dc:creator>Isaac Gouy</dc:creator><description>Thanks AT, I've seen that paper. It's a pity that nullable is taken to be the norm, maybe that's inevitable when the implementation relies on attributes.&lt;br&gt;&lt;br&gt;It's almost worth installing JRE just to try out Nice ;-)&lt;br&gt;</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#150135</link><pubDate>Mon, 07 Jun 2004 16:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:150135</guid><dc:creator>Nicole Calinoiu</dc:creator><description>AT: The Fahndrich and Leino paper describes the _partial_ design and implementation of a static checker. This is potentially very, very far from putting into production a complete non-nullable type system in as tightly integrated a manner as originally described by Cyrus.&lt;br&gt;&lt;br&gt;To be honest, I would see quite a bit of the work described in the paper as an almost equally good starting point for a general declarative validation framework. Many (most?) of the design challenges addressed would be very similar if one were to simply substitute the more general notion of &amp;quot;is valid&amp;quot; for its &amp;quot;is not null&amp;quot; subset.&lt;br&gt;&lt;br&gt;At any rate, I'm very glad that folks at Microsoft are working on this sort of thing, but it doesn't change my opinion in any way regarding my preference for implementation of a declarative validation framework before non-nullable types.</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#150469</link><pubDate>Tue, 08 Jun 2004 00:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:150469</guid><dc:creator>Matt</dc:creator><description>This is infact is/was part of x#/Xen/C-omega.  It is actually very useful construct.  It allows the code using that particular variable assurance that it will never be null.&lt;br&gt;&lt;br&gt;We did indeed look at adding this to C# in Whidbey along side of the new nullable types.  However, we realized that most code written to date in the C# language, API's, etc, already encode non-null semantics using just the normal reference types and runtime checks.  Adding the new non-null type would lead to people choosing to either continue to use plain reference types as parameters, etc, or using the new non-null types to encode non-nullness.  The resulting codebases/frameworks would eventually grow unwieldy because both systems would be in use at the same time.&lt;br&gt;&lt;br&gt;We chose to forgo it for the time being.  It would have been better to introduce this right from the get go.&lt;br&gt;&lt;br&gt;Matt</description></item><item><title>re: Who wants non-nullable types (I do, I do!)?</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#152247</link><pubDate>Thu, 10 Jun 2004 03:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:152247</guid><dc:creator>Orion Adrian</dc:creator><description>&amp;lt;q&amp;gt;We chose to forgo it for the time being. It would have been better to introduce this right from the get go. &amp;lt;/q&amp;gt;&lt;br&gt;&amp;lt;p&amp;gt;Isn't there a way to get around this now. Even if it's just part of the documentation only. It would at least allow tools to analyze the code more easily in the future and the signature itself would give you very valuable information without having to do a lookup (which I do all the time because this information isn't readily available at the &amp;quot;intellisense level&amp;quot;.)&lt;br&gt;&lt;br&gt;Orion Adrian</description></item><item><title>re: Be a language designer...</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#215458</link><pubDate>Tue, 17 Aug 2004 04:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:215458</guid><dc:creator>Eric Gunnerson's C# Compendium</dc:creator><description /></item><item><title>re: Be a language designer...</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#215576</link><pubDate>Tue, 17 Aug 2004 11:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:215576</guid><dc:creator>Eric Gunnerson's C# Compendium</dc:creator><description /></item><item><title>Be a language designer redux...</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#215780</link><pubDate>Tue, 17 Aug 2004 19:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:215780</guid><dc:creator>Eric Gunnerson's C# Compendium</dc:creator><description /></item><item><title>Non-nullable types</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/03/147778.aspx#411619</link><pubDate>Mon, 25 Apr 2005 10:05:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:411619</guid><dc:creator>Cyrus' Blather</dc:creator><description>For those of you who don't read the comments made on other posts of&lt;br&gt;mine, you might be unaware about...</description></item></channel></rss>