More doc fixes
This commit is contained in:
@@ -61,6 +61,11 @@ This patch adds the lua function *genlt* and the C function *lua_genlt*. This is
|
||||
|
||||
This patch is live and functioning. The generalized less-than operator is quite useful as the second parameter to lua's builtin *table.sort* function. We have also provided an iterator *table.sortedpairs* that is similar to the lua builtin *table.pairs* that iterates over a table in sorted order. This implicitly uses the *genlt* comparison operator.
|
||||
|
||||
We originally designed this patch to help with determinism.
|
||||
But we eventually realized it was the wrong design, and we
|
||||
ended up not needing it for determinism. It's still a
|
||||
very useful function, though.
|
||||
|
||||
## The Table Iterator Patch
|
||||
|
||||
This patch is designed to address the nondeterminism of the lua 'next' iterator. In the original Lua design, table iteration was nondeterministic. By that, I mean that in the original lua, I can create two empty tables, I can then perform the same sequence of insertions and deletions on those two tables. The two tables are identical: they have the same keys, and they've had the same same sequence of operations applied to them. But I can iterate over them using "table.pairs", and they produce their keys in two different orders. That's nondeterminism.
|
||||
@@ -170,7 +175,7 @@ That's not bad, but it puts both values and methods into the same namespace:
|
||||
|
||||
- By putting both values and methods into the same namespace, we create the possibility of unintended mistakes.
|
||||
|
||||
I am thinking about implementing a new metatable entry: __METHODS = true. If this flag is present, then the colon operator *obj:method* looks for the method in the metatable, instead of looking for it in the object. With this new metamethod, the way to create a class would be to make a table full of methods, and then in the class table, put __METHODS = true. Then you would do this:
|
||||
I am thinking about implementing a new metatable entry: __METHODS = true. If this flag is present, then the colon operator *obj:method* looks for the method in the metatable, instead of looking for it in the object. With this new metamethod, the way to create a class would be to make a table full of methods, and then in that table, also put __METHODS = true. Then you would do this:
|
||||
|
||||
```lua
|
||||
setmetatable(obj, class)
|
||||
@@ -200,6 +205,6 @@ There's no obvious approach to fixing this, so I haven't patched it yet.
|
||||
|
||||
GC Finalizers and weak tables both introduce nondeterminism into Lua execution. We can't allow that. It may be necessary to patch the lua interpreter to simply disable these functions. Alternately, we could simply ask the scripters not to use these features, and declare "undefined behavior" if they do.
|
||||
|
||||
Update 1: I'm using GC finalizers in some cases to clean up userdata objects. I think it's safe as long as the only thing the finalizer does is free memory.
|
||||
Update 1: I'm using GC finalizers in some cases to clean up userdata objects. I think it's safe as long as the only thing the finalizer does is free memory. (NOTE: WHERE?)
|
||||
|
||||
Update 2: I don't remember using userdata objects at all. I am not sure that Update 1 is the truth any more.
|
||||
|
||||
Reference in New Issue
Block a user