Skip to content

Rewrite the binding system

SquidDev requested to merge feature/better-bindings into master

See 400e2d6a for an initial explanation. The aim here is to deprecate .meta.lua files and define everything inline in the definitions. This has the following benefits:

  • Error reporting is easier (can point out exact positions rather than "meta file is invalid").
  • Easier to automate using macros.
  • Just feels less clunky.

There's still a lot of work to be done on polishing it up:

  • Port all existing libraries to use the new system.
  • Improve existing diagnostics and verify the bindings make sense. For instance, you shouldn't be able to specify :bind-to and :syntax, nor :bind-to and :syntax-fold.
  • Allow specifying signature instead of arity. This will allow us to generate better docs.

It may also be worth copying Lua's documentation into the native bindings, though I don't know a) the legality and b) whether this'll just add too much noise to the docs. Something to investigate.

Any feedback on the syntax, implementation or just general Lua interop is desperately needed. Thanks.

Example

I should probably put an example here, so:

;; Used for defining operators
(define-native ..
  :syntax "${1} .. ${2}" :syntax-precedence  8 :pure :syntax-fold "right")

;; `:bind-to` allows any Lua expression.
(define-native arg :bind-to "arg or {...}")
Edited by SquidDev

Merge request reports