Skip to content Skip to footer
Show HN: Ldump – serialize any Lua data by girvel

Show HN: Ldump – serialize any Lua data by girvel

12 Comments

  • Post Author
    bflesch
    Posted January 31, 2025 at 10:03 am

    Nice – I wonder why something like this is not built-in to the language itself. Especially debugging tables is painful to say the least :)

  • Post Author
    ithkuil
    Posted January 31, 2025 at 10:15 am

    "lump" would have been a nice name

  • Post Author
    sebstefan
    Posted January 31, 2025 at 10:41 am

    So it also dumps functions and is able to import them back?

    Does the function still need to be in memory to be loaded again ("does it just dump the pointer") or can I save it to disk, shut off the interpreter, boot it again and it imports it fine (in which case it somehow dumps them as code…?)?

    Even in the linked test case on the readme you don't show the output/expectation of the serialization

  • Post Author
    lifthrasiir
    Posted January 31, 2025 at 10:54 am

    Maybe I'm too pedantic but allowing anything to be "deserialized", which equals to "evaluated" here, is not secure. I think it only has to accept a very limited subset of Lua anyway, so you may switch to a non-Lua format which is made easy to parse. That way the library has a total control over what is being evaluated.

  • Post Author
    brunocroh
    Posted January 31, 2025 at 11:15 am

    I will try it on my next love2d project, thank you!

  • Post Author
    JourneyJourney
    Posted January 31, 2025 at 11:28 am

    I'm afraid I spent too much time with LUA lately and fell in love with its simplicity. Kinda hard to go back to OOP after that.

  • Post Author
    gvx
    Posted January 31, 2025 at 11:31 am

    Cool to see you were inspired by Ser!

  • Post Author
    synergy20
    Posted January 31, 2025 at 1:54 pm

    newbie question,when is this useful in practice

  • Post Author
    jhatemyjob
    Posted January 31, 2025 at 2:04 pm

    Try running this in a repl and tell me what you get, OP:

        string.format('%q', 'hin')

  • Post Author
    098527222722
    Posted January 31, 2025 at 3:45 pm

    use computer divices

  • Post Author
    koeng
    Posted January 31, 2025 at 3:56 pm

    I've been looking for something similar! Here is what I'd like to do:

    I have a long-running script. At several steps, the execution of the script has to pause for a long time for operations to be done in-real-life (biological experiments, so think wait time being like 2 days between running), before getting some data and continuing to run. From what I can see in this, I'd add yielding coroutines at data pause points, right? How would you handle that?

  • Post Author
    appleorchard46
    Posted January 31, 2025 at 4:02 pm

    Very cool! I was just needing something like this for my Defold game, this looks way better than my hacky solution.

    Semi-unrelated – you say you're using tables as keys in your project. I didn't know you could do that! What are you using it for?

Leave a comment

In the Shadows of Innovation”

© 2025 HackTech.info. All Rights Reserved.

Sign Up to Our Newsletter

Be the first to know the latest updates

Whoops, you're not connected to Mailchimp. You need to enter a valid Mailchimp API key.