-
Notifications
You must be signed in to change notification settings - Fork 49
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
Allow ivar names to be elided #411
Conversation
Linking your comment here: 42b9538#r98502810.
For the module name, yes, they could probably be generated automatically without too much trouble by using the For the instance variable name, I provided a short rationale in #409, but I'll try to expand on it:
But perhaps I'm being pedantic, and nobody actually cares what the name is? What do you think? To avoid conflicts though, I'd probably prefer the name being something like
When I started this project, it was a direct competitor to Another issue with procedural macros is that they're less visible to IDEs, though I'm not sure to what extent this is, and what the recommendations are for overcoming this? Will probably at least require some work to allow the macro to always emit
This is the biggest point for me, complex declarative macros have quite terrible UI.
There are ways to deal with that, see TT munchers performance. For
I would be very interested in a proof-of-concept of replacing e.g. |
Thanks for the detailed response, that clarifies a lot of things.
Good question. I think if it comes down to the choice between better ergonomics for typical, non-debugging use cases (i.e., you just want to declare a class and assume everything is going to work), versus being a little easier to read in the case where things go wrong and you do need to do the debugging, I would probably favor better ergonomics in the typical case. So in that sense, if uniqueness is the issue, I would opt for some autogenerated naming scheme even if the results are a bit unwieldy. I suppose we could still allow the names to be optional in the case that the user really cares, right?
Okay, sounds goods. I will give that a try and we can see what the results look like. |
Yeah, I would be fine with that (though being able to specify it manually is very useful for the case where you want to use I did intentionally remove the ability to specify the class name automatically, since I suspect it's mostly just causes code-smells (e.g. in |
Looking at it again, actually, I think I've been mistaken? If you use In effect, I think it is just be our usage of (This also means that usage of Was/am going to fix this PR as part of #414 anyhow, just writing down my thoughts for now though. |
This PR makes the ivar names optional (re: my earlier comment).
I attempted to do the same for the ivar helper module but it seemed problematic without more serious refactoring of the macros. The reason being that you wouldn't want to create the helper module if there were no ivars specified, but this is hard to detect without more intermediate macros.
One thought I had though is that it feels like many of the macros are rather complicated. I wonder if it might not be worth considering rewriting many of them as proc-macros.
There are the usual downsides to that approach, but on the other hand, it would make some things much easier to implement (like allowing the ivar helper module to be optional) and it would allow us much more control over what kind of error messages we could produce.
I also wonder, especially given the size of
icrate
, whether it might make an impact in terms of performance. As I note in #393, there's at least one framework (Matter
) that I couldn't get to finish compiling even after raising the recursion limit significantly (up to 2048). In that case I think the issue was partly due to a giant enum, which with a proc macro, we could handle with iteration rather than recursion.I realize it would be quite a lot of work to rewrite those but that's something I would be willing to help with if you think it's a good idea.