lua-users home
lua-l archive

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

On Thu, Feb 5, 2009 at 10:05 AM, Ben Harper <> wrote:
> I am using Lua as a language that allows end-users to manipulate
> database records.
> My problem is that I'm not sure how to expose NULL values to the user.
> In this example, value = nil
> User Types:      value .. "abc"
> User Expects:   'abc'
> User Gets:        Error: attempt to concatenate a nil value
> Has anybody had a similar problem, and how have you dealt with it?

I have taken to defining a special global NULL = {} and using that
wherever a NULL is needed, returned, etc. (Not sure about this, but
you could put a metatable on NULL and get concat, plus, etc. to do
something you want.)

Obviously, that may still require knowledge about NULL for the user.
So, the question becomes, do users have to know about NULL? Or can
you, by virtue of being in charge of what's in the DB, hide this
complexity from them.