An unofficial, read-only Hacker News reader.

Lua for data representation (2025) (opens external site)

105 points by vinhnx 5 days ago | citrons.xyz | 61 comments on HN

View full thread · View on Hacker News

Comment thread (3)

  1. You can go further and even register your actual C++ types (e.g. with sol2), which removes lots of extra parsing steps:

        pos = Point(2.5, 8.9)
        size = Size(4, 5)
        opacity = 0.5
        color = Color(0.5, 0.2, 0.1)
    Replies (2)
    1. C types as well (with LuaJIT.). Building metaclasses around SDL objects and adding a tostring function to they can all be printed, for instance. It's so much easier to build a C API in Lua than it is to build a Lua API in C.
    2. You don’t need anything special to do that, you can just export Lua functions that return userdata