lua-users home
lua-l archive

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


> 2014-04-16 10:48 GMT+02:00 steve donovan <steve.j.donovan@gmail.com>:
> > On Wed, Apr 16, 2014 at 10:41 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> >> Quite an attractive idea now that we have so many new metamethods.
> >> Unfortunately string-to-number coercion creates pretty Lua examples
> >> for Gary Bernhardt's next talk on Wat.
> >
> > How strongly do people feel about string-to-number?  It always felt
> > like something that belongs in lesser languages.  What is so hard
> > about explicit tonumber()?
> >
> > Such a change would break some programs yes, but in a very obvious way.
> 
> Roberto has been talking about getting rid of it for a few years,
> and the 5.3 manual already warns:
> 
> Lua also converts strings to numbers, whenever a number is expected.
> (This conversion may be deprecated in future versions.)

There is a big conflict here between some kind of consensus that this
coercion is bad versus a huge impact in compatibility. (Although it is
bad, lots of people use it, frequently unconsciously. The example of
matching with "%d+" is typical.) Maybe we can add a runtime option to
disable this conversion, so that programmers can have an easily available
way to check their code.

-- Roberto