Lurker News

Comments (20) 8 threads

Earlier comments
gonzus1 reply#
In my experience, tying your data format to a programming language is a mistake you most likely will pay for later. For example, when you need access to that data from a different programming language.
code_biologist1 reply#
I agree, but Lua is the singular language that might just maaaybe be the exception to that sometimes.

If you need to access the data from a different language, you just load Lua in the other language.

aa-jv#
Many non-Lua folks don't understand this point: once you've got it in Lua you can put it in anything, anywhere.
Mikhail_Edoshin#
I'd say a tool-command format is a distinct and very good syntax for arbitrary data representation. The input consists of lines; each line starts with a command name, followed by optional arguments. There is some continuation syntax to wrap long arguments. The order of lines matters because each line is executed with its argument by some handler; the handler may modify the execution context. Aside from the command name there is no syntax other than whitespace. And since it quietly accumulates the context it gets very compact too.
binary1321 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),
  }
sudahtigabulan#
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

All comments shown.