Closed shaunsingh closed 8 months ago
Yeah, as you mention this is similar to the situation with #459 as it's about a Lua fork.
At this time I don't think it's a good idea to include support for specialized fork syntax in Fennel itself; there are at least four different forks that all offer their own take on type hints. Since this is fairly unexplored territory, any such development would necessitate a quicker release cycle than Fennel's, as well as the flexibility to make backwards-incompatible changes, making mainline inclusion detrimental.
It should be possible to extend the plugin interface to still allow this to be implemented outside the compiler. I expect that the current state of the plugin system is not extensive enough to support this, but I am certainly open to proposals to extend it in order to enable what you're asking for.
I wonder if the lua
special could be used to just splice in some arbitrary code at an arbitrary place. E.g.:
(fn inc (lua ": number") [x (lua ": number")]
(+ x 1))
It is ugly, but can be made less ugly with a simple macro:
(macro fn+ [name hint args ...]
;; `args` need handling in a similar way
`(fn ,name (lua ,(.. ": " hint)) ,args ,...))
(fn+ inc :number [x :number]
(+ x 1))
I like the idea of @andreyorst, in combination with a library for a luau specific macros.
For example I have been working on a library to add dynamic type checking to Fennel itself, but if adding arbitrary code to the output from a macro becomes possible, i would consider adding type annotations to the output as well.
Not wanting to add support for a fork is fair enough, the macro approach is just as clean. Will certainly look into it. Thanks!
Hi, I was interested in transpiling fennel to luau: https://luau-lang.org, which has a few notable extensions to lua/luajit, mainly type annotations. Fennel already compiles fine down to standard 5.1 syntax, but would a PR adding support for type annotation syntax be accepted? Of course I'd be happy to discuss the syntax and implementation beforehand.
I understand bending or implementing syntax to support forks (e.g. pluto) isn't recommended, but luau is gaining popularity quite heavily in the scripting space (most notably roblox) and so it should be taken under further consideration