David Haley said:
Quote: Lua coerces numbers to strings on the fly when circumstances allow it
Well, if we're getting technical about it ;) no. For example, strings are not coerced for equality testing (which is a problem that was run into in this thread).
Which wasn't the specific scenario that I was alluding to. I also specifically said "when circumstances allow it".
David Haley said: Also, in this instance, it is more likely the C API binding for SetVariable that does the conversion explicitly with lua_isstring and lua_getstring (both of which accept numbers and convert to strings).
Well, yes. If you use lua_getstring on a number, it automatically converts it to a string for you. I'm not sure how that invalidates my point.
David Haley said: The above said: I mentioned explicit conversion for the sake of, well, explicitness, so that consistency is not only implied but also visual. So yes, I told a little white lie. :-)
For the sake of completeness, I thought I'd mention the implicit coercion as well. I wasn't arguing against you, I was supplementing your insight. ;) |