diff options
-rw-r--r-- | lgc.c | 2 | ||||
-rw-r--r-- | manual/manual.of | 23 |
2 files changed, 20 insertions, 5 deletions
@@ -832,7 +832,7 @@ static void GCTM (lua_State *L) { | |||
832 | lua_assert(!g->gcemergency); | 832 | lua_assert(!g->gcemergency); |
833 | setgcovalue(L, &v, udata2finalize(g)); | 833 | setgcovalue(L, &v, udata2finalize(g)); |
834 | tm = luaT_gettmbyobj(L, &v, TM_GC); | 834 | tm = luaT_gettmbyobj(L, &v, TM_GC); |
835 | if (ttisfunction(tm)) { /* is the finalizer a function? */ | 835 | if (!notm(tm)) { /* is there a finalizer? */ |
836 | int status; | 836 | int status; |
837 | lu_byte oldah = L->allowhook; | 837 | lu_byte oldah = L->allowhook; |
838 | int running = g->gcrunning; | 838 | int running = g->gcrunning; |
diff --git a/manual/manual.of b/manual/manual.of index 63e78f95..1e4ca857 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -689,10 +689,8 @@ After the collection, | |||
689 | Lua goes through that list. | 689 | Lua goes through that list. |
690 | For each object in the list, | 690 | For each object in the list, |
691 | it checks the object's @idx{__gc} metamethod: | 691 | it checks the object's @idx{__gc} metamethod: |
692 | If it is a function, | 692 | If it is present, |
693 | Lua calls it with the object as its single argument; | 693 | Lua calls it with the object as its single argument. |
694 | if the metamethod is not a function, | ||
695 | Lua simply ignores it. | ||
696 | 694 | ||
697 | At the end of each garbage-collection cycle, | 695 | At the end of each garbage-collection cycle, |
698 | the finalizers for objects are called in | 696 | the finalizers for objects are called in |
@@ -726,6 +724,9 @@ these marks have no effect. | |||
726 | 724 | ||
727 | Finalizers cannot yield. | 725 | Finalizers cannot yield. |
728 | 726 | ||
727 | Any error while running a finalizer generates a warning; | ||
728 | it is not propagated. | ||
729 | |||
729 | } | 730 | } |
730 | 731 | ||
731 | @sect3{weak-table| @title{Weak Tables} | 732 | @sect3{weak-table| @title{Weak Tables} |
@@ -7279,6 +7280,11 @@ that is, | |||
7279 | with maximum alignment of 1 (no alignment) | 7280 | with maximum alignment of 1 (no alignment) |
7280 | and native endianness. | 7281 | and native endianness. |
7281 | 7282 | ||
7283 | Native endianness assumes that the whole system is | ||
7284 | either big or little endian. | ||
7285 | The packing functions will not emulate correctly the behavior | ||
7286 | of mixed-endian formats. | ||
7287 | |||
7282 | Alignment works as follows: | 7288 | Alignment works as follows: |
7283 | For each option, | 7289 | For each option, |
7284 | the format gets extra padding until the data starts | 7290 | the format gets extra padding until the data starts |
@@ -7288,6 +7294,7 @@ this minimum must be a power of 2. | |||
7288 | Options @St{c} and @St{z} are not aligned; | 7294 | Options @St{c} and @St{z} are not aligned; |
7289 | option @St{s} follows the alignment of its starting integer. | 7295 | option @St{s} follows the alignment of its starting integer. |
7290 | 7296 | ||
7297 | |||
7291 | All padding is filled with zeros by @Lid{string.pack} | 7298 | All padding is filled with zeros by @Lid{string.pack} |
7292 | (and ignored by @Lid{string.unpack}). | 7299 | (and ignored by @Lid{string.unpack}). |
7293 | 7300 | ||
@@ -8720,6 +8727,14 @@ name is visible, even if this other label is declared in an enclosing | |||
8720 | block. | 8727 | block. |
8721 | } | 8728 | } |
8722 | 8729 | ||
8730 | @item{ | ||
8731 | When finalizing an object, | ||
8732 | Lua does not ignore @idx{__gc} metamethods that are not functions. | ||
8733 | Any value will be called, if present. | ||
8734 | (Non-callable values will generate a warning, | ||
8735 | like any other error when calling a finalizer.) | ||
8736 | } | ||
8737 | |||
8723 | } | 8738 | } |
8724 | 8739 | ||
8725 | } | 8740 | } |