← Top stories Lua for data representation (2025) ↗ (opens external site) 104 points by vinhnx 4 days ago | citrons.xyz | 61 comments on HN ↗ View full thread · View on Hacker News Comment thread (5) binary132 | 4 days ago | reply It’s also pretty nice that a verb plus a table is implicitly a function call. This means you can easily do things that seem to be types: m = Menagerie { Dog { tail, ears, snout=long }, Cat { you, get, the=idea }, table.unpack(ark), } Replies (2) sudahtigabulan | 4 days ago | parent | reply This syntax is inherited from one of Lua's predecessors, Sol, for compatibility, and in Sol, it actually means types!There are a couple of snippets here that refer to it (search for @track):https://www.lua.org/history.html spacechild1 | 4 days ago | parent | reply 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) krapp | 4 days ago | parent | reply 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. binary132 | 3 days ago | parent | reply You don’t need anything special to do that, you can just export Lua functions that return userdata
Replies (2)
There are a couple of snippets here that refer to it (search for @track):
https://www.lua.org/history.html
Replies (2)