Replies: 1 comment 2 replies
-
Having thought this over, my opinion is that it seems a little out of scope for Teal itself. Teal as "typed Lua" is both sufficiently valuable and sufficiently focused. That maybe seems contrary because I suggested JSX support in Teal, i.e. On the flipside, Teal's existence as a preprocessor in the Lua ecosystem (which otherwise has no culture of such things, that I'm aware of) presents something of an opportunity, in the way that Babel presented an opportunity for JS to do all sorts of transformations on code and related files. Somehow leveraging its existence to support wider custom transform opportunities seems interesting. Perhaps, the simpler the DSL system, the more it would seem germane to Teal?
This seems workable and uncontroversial. From what I understand, Cyan is a build system, and build systems have a history of executing arbitrary commands as part of the build process. It seems easy to have Cyan call out to The only problem I see is editor support. Making it part of Cyan means that your Teal linter is unaware of your wacky syntax. You do cite some macro types that nuke editor support, but since Teal's mission is to add compile-time and even dev-time safety to Lua, adding a macro system that removes safety seems contrary. You also are likely to lose syntax highlighting with any slight changes.
I think, for the sake of those who aren't familiar with Rust, F# and Linq, it would be helpful to give each one a concrete example in code i.e. what syntax is transformed into what syntax. And how, perhaps, would these affect Teal, and its subsequent transform to Lua? We can do our own research, but since you are familiar, it would be nice to have a summary on hand. Also, based on your concept of these options, which ones would let me write
I think the priority of this should be below quality-of-life improvements such as full autocompletion support in [editor]. Sidebar:
|
Beta Was this translation helpful? Give feedback.
-
So, recently a feature request was made to allow a
tsx
like Syntax to teal. This sparked a bit of a discussion about tsx in Teal as well about DSL's in general.However, as that issue is closed and specific about tsx I decided to make a new discussion about it so more people can weight in.
So, first question first: Should Teal have a way to write custom DSL's?
Second, what would it look like?
These are some examples that I know of:
Going the way of Rust's proc macros is probably overkill and basically kills editor support. However, being just functions that take in a TokenStream and return one, they are very powerful.
Rust's macro_rules! macros are a bit more like it. You give them some patterns and what code to generate using said patterns. However, they end up only being able to do basic transformations.
F#'s Computation expressions are sometimes used as a way to create DSL's. These are actually nice as any value can be used but they don't really create a new syntax.
C#'s Linq expressions suffer from a similar problem as they also can't create new syntax.
I am also not sure if any of these would actually fit in Teal as well, as it isn't exactly something that Lua offers. Having said that, something that I realized later in the original discussion is that it is possible to put the DSL support in Cyan rather than the Teal language.
This can be done by giving Cyan a list of file name patterns and a transform function. When building, Cyan will look for files that fit one of the given pattern and if found gives it to the corresponding transform function. This transform function then will spit out Teal code that is used instead.
This would allow people to write a version of tsx for Teal as well as for other (custom) files like Json schema, sql files, you name it. It would also keep the complexity of DSL's out of Teal itself.
Thoughts on the matter? Should Teal support DSL's? What should they look like? Any other thoughts?
Beta Was this translation helpful? Give feedback.
All reactions