Request for Adoption of Lua Metaprogramming Features in Typst #3925
Replies: 3 comments
-
I think some of the features you mentioned are covered in this blog post : https://laurmaedje.github.io/posts/types-and-context/. |
Beta Was this translation helpful? Give feedback.
-
Thank you , many of the things i tried to discuss are much better said in the blog post mentioned. |
Beta Was this translation helpful? Give feedback.
-
As mentioned, support for custom types is planned. This issue is pretty broad, so that it really feel actionable as a feature request to me. It's maybe better suited as a discussion. For more individual things like operator overloading a feature request might make sense, but I think we shouldn't get ahead of ourselves and add support for custom types at all first. |
Beta Was this translation helpful? Give feedback.
-
Description
Overview
Typst project currently utilizes
typst
for scriptingpurposes. While
typst
serves its purpose adequately, I believeincorporating metaprogramming features inspired by
Lua
could significantlyenhance the flexibility and extensibility of our scripting environment.
Proposal:
I propose the adoption of some of Lua's metaprogramming features within the
project's scripting language.
Lua's metaprogramming capabilities, such as
metatables and metamethods enable powerful customization and extension
of the language's behavior at runtime.
By integrating similar features into our scripting environment, we can empower users to dynamically modify and enhance script behavior to better suit their needs.
Requested Features:
Specific metaprogramming features from Lua that I believe would greatly benefit our project include:
Metatables: Lua's metatables provide a mechanism for defining custom
behaviors for tables, enabling users to implement operator overloading,
custom indexing, and other advanced features within their scripts.
Metamethods: Lua's metamethods allow users to define special methods
that are invoked in response to specific operations (e.g., arithmetic
operations, table access), providing a powerful tool for customizing
script behavior and implementing domain-specific language constructs.
I purposely avoided recommending syntax as that is one of the most subjective and polarizing topics and not worth discussing in this stage.
I welcome feedback and discussion from the community on this proposal, as I understand this is a huge request.
Thank you for considering this request.
Use Case
Examples
For the examples lets create a Dictionary ( object )
Frac
andMatrix
:Beta Was this translation helpful? Give feedback.
All reactions