lua-users home
lua-l archive

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

I'm raising this comment as I see exception-handling mechanisms being
mooted as a replacement some of the cases where "nil" is currently used:

I had the extreme good luck to have an article published once, a long time
ago, in a magazine, where a featured article in that same edition was an
interview with Prof. William Kahan, one of the principal architects of
the IEEE 754 floating-point standard.  Without pretending to be a
numerical analyst myself, I've tried to gain some understanding of his
work and opinions, which have won him numerous highly prestigious awards.

He mentioned in his interview that he was interested in researching
exceptions:  Essentially treating them as opportunities for extra

Kahan's definition, given in that interview, of an place where an
exception would be an appropriate way of dealing with a situation was

     "An exception is an event for which any policy you choose
     in advance will subsequently be found disadvantageous for
     somebody, who will then, for good reason, take exception
     to the policy."

In another part of that article, he talked about how being able to
dynamically change rounding modes could help diagnose deep and tricky
numerical instability cases, yet sometimes overenthusiastic compilers
saw fit to optimise away "obvious" computation -- relying on assumptions
about rounding modes -- that robbed the developer of the capability to
do this trick.

This interview was from the mid-late 1990s, so I suspect that the
compiler (and support numerical libraries) of today are more aware of
these issues than some from earlier times.

Going directly to the current NULL/nil-less-versus-exceptions discussion,
my feeling is that in a world of diverse libraries and reuse scenarios,
adding an exception facility to Lua, in order to eliminate the appearance
of nil, wouldn't be pleasant:  A library may throw an exception that you
weren't expecting (the initial Ariane 5 rocket failure is an extreme case
of an unexpected exception being part (but not all) of a complex failure

Another potential problem could be multiple libraries having incompatible
requirements for exception handling.

So, in summary, for those who advocate to use exceptions instead of nil
and/or NULL, my concern is that they may be making assumptions that are
not sufficiently general, and this could end up being a big problem.