-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Ability to perform reflection on function parameters #21453
Comments
This comment was marked as resolved.
This comment was marked as resolved.
I see how that would be the case for implementing this via |
Ah, my bad, it seems I didn't properly read that line. |
For certain use cases in might be, but this adds a lot of complexity
Yes I agree, needing to reparse your source code in order to do reflection is not an ideal interface. If the compiler has this information already - why not provide in comptime and save the trouble? |
Duplicate of #10706 ? This would be useful for ECS work to remove the need to have a separate specification for which components are expected by a system's update function and makes using the component pointers to find the base pointer less fragile as one cannot mess up the order as is possible now with a separate specification. The reason for not using a struct is suboptimal codegen. So something like this https://godbolt.org/z/dGGG8hb1v would gain from having such. |
There is some overlap, but #10706 to me reads as an idea to move information about declarations from current
While I understand the practical concern of making code fast in status-quo, to me having to trade code organization for better optimizations hints at a flaw in the optimization pipeline (and maybe a language flaw if we're missing a way to express the exact guarantees required). I personally would suggest filing a separate issue for that. |
@rohlem in the example I want use parameter names to pick components of the system rather than having to specify them twice or pass a struct as there is less redundant information present if so. Codegen wise I'm not sure what could be proposed to make the struct passing side better other than having having a way to express |
It is possible to reflect on the types of functions but not their names using
@typeInfo(function).Fn.params
. It would be useful if we had some way of accessing the names of these parameters as well, such as@paramInfo(function)
The specific use case for parameter name reflection is generating luadoc comments from zig functions. See natecraddock/ziglua#94
The ability to perform compile time reflection on parameter names would probably also be useful for any other projects that are generating cross-language bindings or documentation
The text was updated successfully, but these errors were encountered: