Lua diffu-lua-5.4.0-beta-rc1-rc2


README

@@ -1,5 +1,5 @@
 
-This is Lua 5.4.0 (beta), released on 02 Oct 2019.
+This is Lua 5.4.0 (beta), released on 08 Oct 2019.
 
 For installation instructions, license details, and
 further information about Lua, see doc/readme.html.

doc/contents.html

@@ -324,6 +324,38 @@
 <A HREF="manual.html#pdf-utf8.len">utf8.len</A><BR>
 <A HREF="manual.html#pdf-utf8.offset">utf8.offset</A><BR>
 
+<H3><A NAME="metamethods">metamethods</A></H3>
+<P>
+<A HREF="manual.html#2.4">__add</A><BR>
+<A HREF="manual.html#2.4">__band</A><BR>
+<A HREF="manual.html#2.4">__bnot</A><BR>
+<A HREF="manual.html#2.4">__bor</A><BR>
+<A HREF="manual.html#2.4">__bxor</A><BR>
+<A HREF="manual.html#2.4">__call</A><BR>
+<A HREF="manual.html#3.3.8">__close</A><BR>
+<A HREF="manual.html#2.4">__concat</A><BR>
+<A HREF="manual.html#2.4">__div</A><BR>
+<A HREF="manual.html#2.4">__eq</A><BR>
+<A HREF="manual.html#2.5.3">__gc</A><BR>
+<A HREF="manual.html#2.4">__idiv</A><BR>
+<A HREF="manual.html#2.4">__index</A><BR>
+<A HREF="manual.html#2.4">__le</A><BR>
+<A HREF="manual.html#2.4">__len</A><BR>
+<A HREF="manual.html#2.4">__lt</A><BR>
+<A HREF="manual.html#pdf-getmetatable">__metatable</A><BR>
+<A HREF="manual.html#2.4">__mod</A><BR>
+<A HREF="manual.html#2.5.4">__mode</A><BR>
+<A HREF="manual.html#2.4">__mul</A><BR>
+<A HREF="manual.html#luaL_newmetatable">__name</A><BR>
+<A HREF="manual.html#2.4">__newindex</A><BR>
+<A HREF="manual.html#pdf-pairs">__pairs</A><BR>
+<A HREF="manual.html#2.4">__pow</A><BR>
+<A HREF="manual.html#2.4">__shl</A><BR>
+<A HREF="manual.html#2.4">__shr</A><BR>
+<A HREF="manual.html#2.4">__sub</A><BR>
+<A HREF="manual.html#pdf-tostring">__tostring</A><BR>
+<A HREF="manual.html#2.4">__unm</A><BR>
+
 <H3><A NAME="env">environment<BR>variables</A></H3>
 <P>
 <A HREF="manual.html#pdf-LUA_CPATH">LUA_CPATH</A><BR>

@@ -625,7 +657,7 @@
 
 <P CLASS="footer">
 Last update:
-Mon Sep 30 23:54:47 UTC 2019
+Thu Oct  3 17:35:42 UTC 2019
 </P>
 <!--
 Last change: revised for Lua 5.4.0 (beta)

doc/manual.html

@@ -397,9 +397,9 @@
 Every value in Lua can have a <em>metatable</em>.
 This <em>metatable</em> is an ordinary Lua table
 that defines the behavior of the original value
-under certain special operations.
+under certain events.
 You can change several aspects of the behavior
-of operations over a value by setting specific fields in its metatable.
+of a value by setting specific fields in its metatable.
 For instance, when a non-numeric value is the operand of an addition,
 Lua checks for a function in the field "<code>__add</code>" of the value's metatable.
 If it finds one,

@@ -410,7 +410,7 @@
 The key for each event in a metatable is a string
 with the event name prefixed by two underscores;
 the corresponding values are called <em>metamethods</em>.
-In the previous example, the key is "<code>__add</code>"
+In the previous example, the key is the string "<code>__add</code>"
 and the metamethod is the function that performs the addition.
 Unless stated otherwise,
 metamethods should be function values.

@@ -440,26 +440,10 @@
 
 
 <p>
-A metatable controls how an object behaves in
-arithmetic operations, bitwise operations,
-order comparisons, concatenation, length operation, calls, and indexing.
-A metatable also can define a function to be called
-when a userdata or a table is garbage collected (<a href="#2.5">&sect;2.5</a>).
-
-
-<p>
-For the unary operators (negation, length, and bitwise NOT),
-the metamethod is computed and called with a dummy second operand,
-equal to the first one.
-This extra operand is only to simplify Lua's internals
-(by making these operators behave like a binary operation)
-and may be removed in future versions.
-(For most uses this extra operand is irrelevant.)
-
-
-<p>
-A detailed list of events controlled by metatables is given next.
-Each operation is identified by its corresponding key.
+A detailed list of operations controlled by metatables is given next.
+Each event is identified by its corresponding key.
+By convention, all metatable keys used by Lua are composed by
+two underscores followed by lowercase Latin letters.
 
 
 

@@ -469,16 +453,16 @@
 the addition (<code>+</code>) operation.
 If any operand for an addition is not a number,
 Lua will try to call a metamethod.
-First, Lua will check the first operand (even if it is valid).
-If that operand does not define a metamethod for <code>__add</code>,
+It starts by checking the first operand (even if it is a number);
+if that operand does not define a metamethod for <code>__add</code>,
 then Lua will check the second operand.
 If Lua can find a metamethod,
 it calls the metamethod with the two operands as arguments,
 and the result of the call
 (adjusted to one value)
 is the result of the operation.
-Otherwise,
-it raises an error.
+Otherwise, if no metamethod is found,
+Lua raises an error.
 </li>
 
 <li><b><code>__sub</code>: </b>

@@ -585,7 +569,7 @@
 Behavior similar to the addition operation,
 except that Lua will try a metamethod only when the values
 being compared are neither both numbers nor both strings.
-The result of the call is always converted to a boolean.
+Moreover, the result of the call is always converted to a boolean.
 </li>
 
 <li><b><code>__le</code>: </b>

@@ -636,9 +620,9 @@
 <p>
 Whenever there is a <code>__newindex</code> metamethod,
 Lua does not perform the primitive assignment.
-(If necessary,
+If needed,
 the metamethod itself can call <a href="#pdf-rawset"><code>rawset</code></a>
-to do the assignment.)
+to do the assignment.
 </li>
 
 <li><b><code>__call</code>: </b>

@@ -650,17 +634,32 @@
 the metamethod is called with <code>func</code> as its first argument,
 followed by the arguments of the original call (<code>args</code>).
 All results of the call
-are the result of the operation.
+are the results of the operation.
 This is the only metamethod that allows multiple results.
 </li>
 
 </ul>
 
 <p>
-It is a good practice to add all needed metamethods to a table
-before setting it as a metatable of some object.
-In particular, the <code>__gc</code> metamethod works only when this order
-is followed (see <a href="#2.5.3">&sect;2.5.3</a>).
+In addition to the previous list,
+the interpreter also respects the following keys in metatables:
+<code>__gc</code> (see <a href="#2.5.3">&sect;2.5.3</a>),
+<code>__close</code> (see <a href="#3.3.8">&sect;3.3.8</a>),
+<code>__mode</code> (see <a href="#2.5.4">&sect;2.5.4</a>),
+and <code>__name</code>.
+(The entry <code>__name</code>,
+when it contains a string,
+is used by some error-reporting functions to build error messages.)
+
+
+<p>
+For the unary operators (negation, length, and bitwise NOT),
+the metamethod is computed and called with a dummy second operand,
+equal to the first one.
+This extra operand is only to simplify Lua's internals
+(by making these operators behave like a binary operation)
+and may be removed in future versions.
+For most uses this extra operand is irrelevant.
 
 
 <p>

@@ -672,6 +671,15 @@
 use other fields in metatables for their own purposes.
 
 
+<p>
+It is a good practice to add all needed metamethods to a table
+before setting it as a metatable of some object.
+In particular, the <code>__gc</code> metamethod works only when this order
+is followed (see <a href="#2.5.3">&sect;2.5.3</a>).
+It is also a good practice to set the metatable of an object
+right after its creation.
+
+
 
 
 

@@ -1232,7 +1240,7 @@
 The UTF-8 encoding of a Unicode character
 can be inserted in a literal string with
 the escape sequence <code>\u{<em>XXX</em>}</code>
-(with mandatory enclosing brackets),
+(with mandatory enclosing braces),
 where <em>XXX</em> is a sequence of one or more hexadecimal digits
 representing the character code point.
 This code point can be any value less than <em>2<sup>31</sup></em>.

@@ -7072,7 +7080,6 @@
 adds to this new table the pair <code>__name = tname</code>,
 adds to the registry the pair <code>[tname] = new table</code>,
 and returns 1.
-(The entry <code>__name</code> is used by some error-reporting functions.)
 
 
 <p>

@@ -7566,7 +7573,7 @@
 some kind of failure or the absence of a better value to return.
 Currently, <b>fail</b> is equal to <b>nil</b>,
 but that may change in future versions.
-The recommendation is to test the success of these functions
+The recommendation is to always test the success of these functions
 with <code>(not status)</code>, instead of <code>(status == nil)</code>.
 
 

@@ -11081,7 +11088,7 @@
 <li><code>limit</code> cannot be less than the amount of C stack in use.</li>
 </ul><p>
 If a call does not respect some restriction,
-it returns <b>false</b>.
+it returns a falsy value.
 Otherwise,
 the call returns the old limit.
 

@@ -11698,7 +11705,7 @@
 
 <P CLASS="footer">
 Last update:
-Wed Oct  2 21:30:38 UTC 2019
+Tue Oct  8 15:13:21 UTC 2019
 </P>
 <!--
 Last change: revised for Lua 5.4.0 (beta)

doc/readme.html

@@ -278,7 +278,7 @@
 <LI> new semantics for the integer 'for' loop
 <LI> optional 'init' argument to 'string.gmatch'
 <LI> new functions 'lua_resetthread' and 'coroutine.close'
-<LI> coersions string-to-number moved to the string library
+<LI> string-to-number coercions moved to the string library
 <LI> allocation function allowed to fail when shrinking a memory block
 <LI> new format '%p' in 'string.format'
 <LI> utf8 library accepts codepoints up to 2^31

@@ -329,7 +329,7 @@
 
 <P CLASS="footer">
 Last update:
-Tue Sep 24 16:42:41 UTC 2019
+Thu Oct  3 12:42:49 UTC 2019
 </P>
 <!--
 Last change: revised for Lua 5.4.0 (beta)

src/Makefile

@@ -141,8 +141,6 @@
 lcode.o:
 	$(CC) $(CFLAGS) -Os -c lcode.c
 
-	
-
 # DO NOT DELETE
 
 lapi.o: lapi.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \

src/lcode.c

@@ -1650,8 +1650,8 @@
     case OPR_SUB: {
       if (finishbinexpneg(fs, e1, e2, OP_ADDI, line, TM_SUB))
         break; /* coded as (r1 + -I) */
-      /* ELSE *//* FALLTHROUGH */
-    }
+      /* ELSE */
+    }  /* FALLTHROUGH */
     case OPR_DIV: case OPR_IDIV: case OPR_MOD: case OPR_POW: {
       codearith(fs, opr, e1, e2, 0, line);
       break;

src/lcorolib.c

@@ -116,7 +116,8 @@
 #define COS_NORM	3
 
 
-static const char *statname[] = {"running", "dead", "suspended", "normal"};
+static const char *const statname[] =
+  {"running", "dead", "suspended", "normal"};
 
 
 static int auxstatus (lua_State *L, lua_State *co) {

src/ldblib.c

@@ -24,7 +24,7 @@
 ** The hook table at registry[HOOKKEY] maps threads to their current
 ** hook function.
 */
-static const char* HOOKKEY = "_HOOKKEY";
+static const char *const HOOKKEY = "_HOOKKEY";
 
 
 /*

src/lgc.c

@@ -998,7 +998,7 @@
 */
 static GCObject **sweepgen (lua_State *L, global_State *g, GCObject **p,
                             GCObject *limit) {
-  static lu_byte nextage[] = {
+  static const lu_byte nextage[] = {
     G_SURVIVAL,  /* from G_NEW */
     G_OLD1,      /* from G_SURVIVAL */
     G_OLD1,      /* from G_OLD0 */

src/loadlib.c

@@ -59,7 +59,7 @@
 ** key for table in the registry that keeps handles
 ** for all loaded C libraries
 */
-static const char *CLIBS = "_CLIBS";
+static const char *const CLIBS = "_CLIBS";
 
 #define LIB_FAIL	"open"
 

src/lparser.c

@@ -1523,8 +1523,8 @@
 */
 static void forbody (LexState *ls, int base, int line, int nvars, int isgen) {
   /* forbody -> DO block */
-  static OpCode forprep[2] = {OP_FORPREP, OP_TFORPREP};
-  static OpCode forloop[2] = {OP_FORLOOP, OP_TFORLOOP};
+  static const OpCode forprep[2] = {OP_FORPREP, OP_TFORPREP};
+  static const OpCode forloop[2] = {OP_FORLOOP, OP_TFORLOOP};
   BlockCnt bl;
   FuncState *fs = ls->fs;
   int prep, endfor;

src/lstrlib.c

@@ -233,6 +233,17 @@
 ** =======================================================
 */
 
+#if defined(LUA_NOCVTS2N)	/* { */
+
+/* no coercion from strings to numbers */
+
+static const luaL_Reg stringmetamethods[] = {
+  {"__index", NULL},  /* placeholder */
+  {NULL, NULL}
+};
+
+#else		/* }{ */
+
 static int tonum (lua_State *L, int arg) {
   if (lua_type(L, arg) == LUA_TNUMBER) {  /* already a number? */
     lua_pushvalue(L, arg);

@@ -311,6 +322,8 @@
   {NULL, NULL}
 };
 
+#endif		/* } */
+
 /* }====================================================== */
 
 /*

src/luac.c

@@ -508,15 +508,15 @@
 	break;
    case OP_MMBIN:
 	printf("%d %d %d",a,b,c);
+	printf(COMMENT "%s",eventname(c));
 	break;
-	printf(COMMENT); printf("%s ",eventname(c));
    case OP_MMBINI:
 	printf("%d %d %d",a,sb,c);
-	printf(COMMENT); printf("%s ",eventname(c));
+	printf(COMMENT "%s",eventname(c));
 	break;
    case OP_MMBINK:
 	printf("%d %d %d",a,b,c);
-	printf(COMMENT); printf("%s ",eventname(c)); PrintConstant(f,b);
+	printf(COMMENT "%s ",eventname(c)); PrintConstant(f,b);
 	break;
    case OP_UNM:
 	printf("%d %d",a,b);

@@ -635,9 +635,12 @@
 	printf("%d",ax);
 	printf(COMMENT); PrintConstant(f,ax);
 	break;
-   //default: printf("not handled"); break;
-	//printf("%d %d %d",a,b,c);
-	//break;
+#if 0
+   default:
+	printf("%d %d %d",a,b,c);
+	printf(COMMENT "not handled");
+	break;
+#endif
   }
   printf("\n");
  }