|
string.dump - cannot dump functions
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
WinkleWinkle
USA (5 posts) bio
|
| Date |
Mon 27 Jun 2011 03:16 AM (UTC) [ quote
] |
| Message |
I'm having huge issues in Aardwolf Mushclient v 1040 with string.dump!
I am using the example script in the help file and I'm getting the same error in my plugin as well as a test alias
Run-time error
World: Aardwolf
Immediate execution
[string "Alias: "]:2: cannot dump functions
stack traceback:
[C]: in function 'dump'
[string "Alias: "]:2: in main chunk
The code I'm using is copied from the help file and it is:
function f () print "hello, world" end
s = string.dump (f)
assert (loadstring (s)) () --> hello, world
Now.. when i run this code in http://www.lua.org/cgi-bin/demo, it works fine.. but not in mush. The whole point of string.dump is to dump functions, why is the error message saying "cannot dump functions" ?
WinkleWinkle | top |
|
| Posted by |
WinkleWinkle
USA (5 posts) bio
|
| Date |
Reply #1 on Mon 27 Jun 2011 03:19 AM (UTC) [ quote
] |
| Message |
PS, my test alias looks like this:
<aliases>
<alias
match="__test"
enabled="y"
send_to="12"
sequence="100"
>
<send>function f () print "hello, world" end
s = string.dump (f)
assert (loadstring (s)) () --> hello, world</send>
</alias>
</aliases>
PPS I'm not a new lua coder (using anonymous functions and function pointers before), but i'd be happy if i'm missing soemthing obvious like a requires statement | top |
|
| Posted by |
Nick Gammon
Australia (18,772 posts) bio
Forum Administrator |
| Date |
Reply #2 on Mon 27 Jun 2011 03:59 AM (UTC) [ quote
] |
| Message |
Hmm. Two things here. First is, this is because you (or Aardwolf) is using LuaJIT. That does not support dumping functions. I finally worked it out after searching for "cannot dump functions" in the source - that message just isn't there.
But if you Google: luajit "cannot dump functions"
... you will find some matches.
One workaround is to put in the "normal" Lua DLL (the one that ships with standard MUSHclient).
Quote:
... when i run this code in http://www.lua.org/cgi-bin/demo, it works fine.. but not in mush ...
That is because Fiendish is using the LuaJIT DLL.
However I really seriously have to wonder why you are dumping functions. I have written many many lines of Lua code, and I never dump them.
I strongly suggest rethinking your design. There should be no need for dumping functions. Perhaps if you describe what you are trying to achieve? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
Fiendish
USA (849 posts) bio
Global Moderator |
| Date |
Reply #3 on Mon 27 Jun 2011 04:55 AM (UTC) [ quote
] Amended on Mon 27 Jun 2011 08:13 AM (UTC) by Fiendish
|
| Message |
WARNING. If you replace the lua dll with one that is not luajit 2.0, the mapper plugin will fail during backup because it uses FFI. Just, you know, a heads up. Also, performance will suffer.
The new b8 version of luajit supports bytecode dumping and loading, so if you REALLY need to use string.dump just wait a day or so. I'll have the new version up in a snapshot by then. I really doubt you need it, but be happy to know that you'll be able to in the next snapshot.
[EDIT] The new snapshot is up now. https://code.google.com/p/aardwolfclientpackage/downloads/list |
http://aardwolfclientpackage.googlecode.com/ | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
1,248 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )