I am actually using C# - but the question of Nulls came up on a local developers group (Chester Devs, UK) social site about the issues with nulls
An object Person has a property, say Name, of type String If the name is not known then in C# Name is null
Does Eiffel have a better way than C# ( if x is null ...) to deal with this common dynamic void ?
Eiffel allows for
voidvalues (nullin C#). However it makes sure there is never a call on a void target (i.e., there is noNullReferenceException). This is ensured at compile time by relying on the type system that is augmented withattached/detachablenotion of a type and on a set of special void-safety rules that guarantee that any expression of an attached type is always attached to an object at run-time (i.e. is nevernull).In your example, the class declaration will look like
Then in the code it can be used as
It might be possible to have an
OPTIONtype and rely on it when some value may be present or absent, but absence of a value is naturally represented byvoid, this is what it is designed for, so usually there is little need for a special type.