Reply to post: Re: Null pointers

Mads Torgersen and Dustin Campbell on the future of C#

AndrueC Silver badge
Happy

Re: Null pointers

This isn't about the underlying value. In C# NULL (actually 'null') is a keyword. It has a very specific meaning of 'doesn't point to anything'. It's underlying numeric value is already irrelevant. A C# pointer isn't just an integer that the compiler lets you dereference. A pointer is a specific thing and has dedicated semantics. This means it can be tracked through the code using analysis. In

C#/.NET allows for better analysis so the compiler (and the IDE thanks to Roslyn) can understand the concept. What they seem to be suggesting is allowing a variable to have a '?' suffix to indicate that NULL values are permissable. So with this change any code that currently issues the warning 'Possible System.NulReference Exception' wouldn't compile unless the variable had a '?' suffix. That coupled with static analysis would ensure that pointers which should never be null will, in fact, never be null.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon