lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Except it's not even about correct code. Depending on the implementation of a language its not unreasonable to attach methods to the nill type. This would make sense for something like string conversion:

nil.toString() == "nil"

Languages like Clojure also allow for this by simply extending most protocols to accept nils. So calling (count nil) returns 0. If you embrace nils, they stop becoming a hazard and start becoming just another value that has some methods and doesn't have others.

The whole deal about NULL being a "billion dollar mistake" is really completely bogus in a well designed dynamic language.


On Mon, Jan 12, 2015 at 2:10 PM, Robert Virding <> wrote:
Yes, it would be a terrible thing. Worst case it might actually force programmers to write correct code and code which can sensibly handle errors. I mean, where would it end?


On 10 January 2015 at 11:43, Rob Kendrick <> wrote:
On Fri, Jan 09, 2015 at 09:45:40PM +0100, Enrique Arizón Benito wrote:
> Hi,
> as Rob Kendrick indicated, replacing nil and raising an exception is the
> only possibility. (and it's a good thing to do, since this avoid the
> program to continue with an un-initialized variable).

But I actually indicated that it was a horrible thing to do :)


“One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.”
(Robert Firth)