|
于 2013-12-21 17:24, Ulrich Schmidt 写道:
I wrote a
tiny module to print some values to console for debugging
purposes. (see attaches file)
It works well on luaJIT and lua52. I can require it in zbs
sucessfully but when i try to use it like ..
-- 8< ----------------------------
D=require"D"
D(_G)
-- 8< ----------------------------
.. i get a error.
I have no idea whats wrong.
Greetings.
Ulrich.
Am 16.12.2013 05:16, schrieb Paul K:
ZeroBrane Studio is a lightweight Lua IDE
with code completion, syntax
highlighting, live coding, remote debugger, code analyzer, and
integration with various Lua engines.
Some of the changes in this release:
- Added LuaDist integration (requires a plugin [1]).
- Added live coding support for GSL-shell.
- Added support for project settings (requires a plugin [2]).
- Added filetree operations (rename/move/delete for
files/directories).
- Added Busted interpreter.
- Other improvements (full release details are in the changelog
[3]).
Installation packages for Windows, OSX, and Linux are available
on the
project website: http://studio.zerobrane.com. Thank you for all
the
contributions, feedback, and support of the project!
Paul.
[1]
https://github.com/pkulchenko/ZeroBraneStudio/issues/225#issuecomment-27532676
[2]
https://github.com/pkulchenko/ZeroBraneStudio/issues/107#issuecomment-26830619
[3]
https://github.com/pkulchenko/ZeroBraneStudio/blob/master/CHANGELOG.md
after reading your code and some debugging work, I think I have
found the reason.
in the function "pairsByKeys", you first get all keys of a table and
store them sorted.
then you return an iterator which walk throgh the sorted keys.
this is all fine, as long the table is a _normal_ table.
the potential problem might occur in such case that the table has
the __index meta method
which would have some side effects when you index into that table.
in this special case where ZBS give the error message:
>wxLua: Attempt to call a static class method using 'nil' on a
'wxANIHandler' type.
> [C]: in function '__index'
which I guess the table is just a proxy for a object of the class
wxANIHandler.
so you actually got no keys at all in that proxy table, thus the
sorted keys are empty.
the the code on line 60
> return a[i], t[a[i]]
actually translated as
> return nil, t[nil]
thus the __index meta method of the proxy is called with a nil
value, thus the error.
A simple work aroud won't give errors as I tested.
Just change that line as follows:
> return a[i], a[i] and t[a[i]]
which would index the table only if the key _does exists_.
Good luck.
|