[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: tostring() and the "not even nil" type.
- From: Pierre-Yves GÃrardy <pygy79@...>
- Date: Thu, 29 Apr 2010 21:31:13 +0200
> = tostring(a()) --> Error.
> = tostring(select(2)) --> Ditto.
tostring() throws an error when it doesn't receive any argument. Since
it is often called to sanitize a result before concatenation, it could
make sense if it returned "nil", or even the empty string instead.
In most other circumstances, these "lack of value" are converted to
nil, but not here.
A partial solution is to append "or nil" to the argument of every
risky tostring() call, but it would be more elegant if it were handled
at the language level.