[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Syntactic sugar idea: Safe use of nil
- From: Jamie Webb <j@...>
- Date: Mon, 28 Jun 2004 23:29:47 +0100
On Monday 28 June 2004 23:18, Dan East wrote:
> Dimitris Papavasiliou wrote:
> > Indexing a nil value is undefined so you would expect
> > it to cause an error.
> What if indexing a nil value returned nil instead of throwing an
Because usually indexing a nil represents a bug, and that behaviour would make
tracking down such bugs extremely painful. You can't even make it optional
once programmers start relying on 'nil propagation'.
In general, I think nil values are rather like gotos: they are occasionally
expedient, but in general they lead to unmaintainable code, and so programs
should usually be designed to avoid them. In time, I hope that nils will be
removed from programming languages in the same way as gotos have been, and
replaced with option types, as found in e.g. ML.
-- Jamie Webb