If nil was not present, some points come to my mind that would need some special care:
- Function arguments need default arguments as the caller might not even know what's called.
- A function may return any number of values, including none. Assigning results from calls will need a creative solution to work this out
- Any table access would need to declare what type or default value is expected as a table contains an infinite amount of nils right now
- Error indication is currently done through returning nil,"error message". This would need some different treatment if you really intend to check variable types, since this is a primary example where return value types are not expected to be the same for every call.
I think that the later 2 points might be tackled with one solution, however it should respect the multiple-value assignment operation in Lua. Something like
x,y,z = foo(1,2,3)
needs some kind of indication what x,y,z should become if foo is not returning three values. A simple solution could be to introduce a "no-value" special value, but let's be honest, that'd be just nil with another name :). I think something more like
x,y,z = foo(1,2,3) as 0,0,0
would be closer to what would be expected. Not specifying default values for return values would result in an runtime error if that function wouldn't return the expected amount of arguments.
Declaring functions could use the same idiom, like
function foo (x as 0, y as 0, z as 0)
I think it might be interesting to follow this just for fun (if you have the time). There might be some interesting lessons in it. I believe however that yesterdays problems(tm) will be just traded with tomorrow problems(tm) ;)
Tackling absent values in Lua isn't such a big deal as in C where it can have quite "interesting" effects, beginning with the fact that pointer arithmetics aren't available in Lua...
Cheers,
Eike