@Bortels Sorry for reviving an old thread but above you mentioned that the DataDumper revised code:
More fun - it works unmodified - just load that gist into a blank tab, and...
So, as a clueless neophyte, I’ve just tried pasting said unmodified code into a blank tab and found (before I even tried invoking the function in main) that the code choked on this line:
if totallen ]] > 80 then
with a – ‘then’ expected near ‘]’ – error.
Any ideas? Does the DataDumper function still work for you?
I’ll try again… ah thanks!.. it now runs… mea culpa, you were right there must have been something funky with my cut and paste…
However… now when I call DataDumper (using your {“hello”, “world”} table for testing) Codea protests its confusion concerning getfenv(), a function which, at least according to Mr. Zoyd’s recent posts, is under embargo in the sandbox file.
Must I live dangerously to serialize/save tables and functions with up-values?
Edit: Thinking about this a bit I can imagine the ability to serialize tables and functions might be a giant step beyond loadstring on Apple’s slippery slope.
It worked when I posted it; a quick google (all that I have time for right now, I’m on the way to work) suggests this was removed in Lua 5.2? (and I think the Lua Codea uses was upgraded between then and now, although I’m not sure.) I’m also not sure how relevant that call is in the iOS/Codea context anyway - I suspect it could be stubbed out or otherwise dealt with. Keep in mind - I did not write the code in question, I just found/ported it, and as I noted the port was trivial, code being basically unchanged - there’s still very deep voodoo in it I won’t claim to fully understand.
I believe - again, based on a quick scan - that this chunk of code only deals with “userdata” - in our case, things like image() and mesh(). If your data structure is a pure lua-element-only table, I suspect this chunk of code could simply be commented out.
Well - if it’s not Lua 5.2, my only other thought is that they must have sandboxed that function at some point, because I promise - the code worked for me when I posted it. Scout’s Honor. Or, maybe I just never tried using it on something that triggered that call?
we'll probably expose some more in the next release.
@Simeon that would be swell! (hopefully getfenv in 1.3.1?)
@Bortels the call to getfenv() was triggered using your own {“hello”, “world”} example! But hey… no problem. Thank you for all your help.
Edit:
I believe - again, based on a quick scan - that this chunk of code only deals with "userdata" - in our case, things like image() and mesh(). If your data structure is a pure lua-element-only table, I suspect this chunk of code could simply be commented out.
As far as I can tell (I hope I am not saying something stupid here-- my understanding of all this is rudimentary to the extreme) the chunk of code in question allows the dumping of closures with the up-value preserved – a feat which string.dump can’t do in 5.1. (I believe it is possible in 5.2 but only with a reset up-value.)
And please don’t disable LoadString (although I’d rather sockets than LoadString) because I was looking into making a Codea Jr. kind of like Scratch (look it up). You would drag in little chunks of code, and it would execute them when you press run. I’d also integrate a few other librarys out there.
@Zoyt thanks I’ve seen your thread. You might think me crazy but I’d rather keep my system kosher if possible. Especially as a lua/Codea newbie. But again thanks!
Ya, I hack around with Codea a lot… It doesn’t seem to affect anything else. I do it for fun… Mainly. And I don’t think you’re crazy… You might as well call me crazy.