[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Patch to remove auto-casting between numbers and strings
- From: Reuben Thomas <rrt@...>
- Date: Fri, 8 Sep 2006 09:21:51 -0300 (BRT)
I have worked up a patch (against 5.1.1) that removes auto-casting
between numbers and strings. It currently works in most of the major
cases (arithmetic, concatenation, #) although there's still some work to
do in the libraries.
The reason I'm posting about it is to ask if anyone else is interested.
1. Would anyone like the patch? If so, I'd check the library cases a bit
more carefully and document what I did.
2. Would it be interesting enough to make it a compile-time option? From
looking at the code it would seem possible to replace internal calls to
various tonumber and tostring options with "casttonumber" and
"casttostring", which could have appropriate compile-time definitions.
Motivation for the patch: I don't like automatic casting; it hides bugs.
I also think it rarely helps users, and if it does (e.g. in a config
file), then you can do the auto-casting yourself (e.g. read a config
file, and call "to<type>(v)" on each value you read).
For example, print is one function I've left alone. This is an
example of the fine line in Lua between auto-casting and intentionally
calling a tostring method.
http://rrt.sc3d.org/ | The old cliches are the best