-
Notifications
You must be signed in to change notification settings - Fork 224
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
Stringify on AnyPointer
#397
Comments
It sounds like you are suggesting using global mutable state? I think we should avoid that. What if we instead exposed a public version of |
Yes, I'm aware that a global state is not a good design :-(. Unfortunately, I couldn't find anything better that would work with Thinking it further, though, one option would be to somehow integrate it with annotations. I.e., if there is an annotation on There are some issues, though:
This can be done on our side as well, so no need to do it directly in the
It is definitely not a deal-breaker to NOT to have this at all, since we can add an own wrapper which does the necessary evaluation, it just needs to be used everywhere instead of the plain |
Now that dynamic reflection landed in capnp-rust (big thanks to David), we can easily
Debug
-print anycapnp
struct. However, these structs may containAnyPointer
, which currently doesn't print its own contents (for obvious reasons).For example, in our project, we use
AnyPointer
in a generic outer request type to store the inner request. The inner request's structure ID is stored in the generic part and it's used for dispatching the inner request in the server. Now that we have reflection, we can print the contents of the outer and inner request for debugging purposes using our hand-craftedDebug
implementation, based on the standard implementation in capnp.However, I assume, our project is not the only one which uses
AnyPointer
. So the suggestion is to add a anyptr-debug-print hook to register a method to interpret theAnyPointer
as a pointer to something else and/or to print it in the hook itself by dynamically evaluating the current structure containing theAnyPointer
in question via the hook. Unfortunately, the formatter currently just gets the access to the pointer, but not to the outer structure, so theprint
function would require additional parameters for the optional parent dynamic structure and parent's field index which is being evaluated to be able to pass them to the hook to reinterpret theAnyPointer
properly.Opinions?
The text was updated successfully, but these errors were encountered: