Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Bug reports ➜ string.dump - cannot dump functions

string.dump - cannot dump functions

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by WinkleWinkle   USA  (5 posts)  Bio
Date Mon 27 Jun 2011 03:16 AM (UTC)
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)
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)) () --&gt; 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  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Mon 27 Jun 2011 03:59 AM (UTC)
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  (2,558 posts)  Bio   Global Moderator
Date Reply #3 on Mon 27 Jun 2011 04:55 AM (UTC)

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

https://github.com/fiendish/aardwolfclientpackage
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.


15,460 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.