-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Proposal] Utilize macros #101
Comments
Yes, some way of working as a macro has been in my long-term vision for ructe pretty much since the start. So It's nice to finally having an issue for it. :-) I have mainly had something like |
It would be nice if templates could be rendered without using build scripts.
The current approach is not very bad, but it could be more ergonomic with macros.
The pro for using macros is that special build scripts would be unnecessary, and this crate would no longer need "special treatment" to set up. It might also be friendlier for development tools, but I am not entirely sure on this point.
The con is that, as far as I understand, this would require setting up another
ructe-codegen
crate that hosts the procedural macro(s). This might also require exposing some previously private apis in altered form.For what an api using macros could look like, something like this comes to mind:
At least naively implemented, this has the disadvantage that templates will need to be parsed once for every use of that template. Also having so many arguments is just not very pretty or readable.
Alternatively, something like
might be worth considering even though it is imo less intuitive because the macro looks more like a function call than a function definition.
where
template!
returns an instance of some struct generated from within the macro might also work.As you can tell, this idea is not very fleshed out yet, but I believe it has a lot of potential in making the library easier to use, and I would love to hear ideas and opinions on the matter.
The text was updated successfully, but these errors were encountered: