lua-users home
lua-l archive

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


I would be happy to try this. I'll upgrade to the latest and apply this change first thing tomorrow. 

On Sunday, March 23, 2014, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> I'd like to suggest that the timing for changes to coercion is in this
> release.
>
> You introduced int 64 and language support for bits, plus changes to number
> formatting. 5.3 looks to be shaping up to be a "number" release.
> Eliminating string->number fits this.

I am afraid elimination of this conversion is a much deeper disruption
than it seems; I would love to be proved wrong.

I think it is really easy to disable this coercion in Lua; all it takes
is a simple change in lvm.c (see below). It would be very helpful if
people try that in the wild and report their experiences here in the
list.


Lua 5.1 and Lua 5.2:
@@ -35,10 +35,6 @@
 const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
   lua_Number num;
   if (ttisnumber(obj)) return obj;
-  if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
-    setnvalue(n, num);
-    return n;
-  }
   else
     return NULL;
 }

Lua 5.3:
@@ -44,7 +44,7 @@
     return 1;
   }
   else
-    return (ttisstring(obj) && luaO_str2d(svalue(obj), tsvalue(obj)->len, n));
+    return 0;
 }


-- Roberto