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
implement interfaces at runtime [was: methods declared in the interpreter are not visible in compiled code] #45
Comments
You took the red pill :) It's a bit hidden in doc/features-and-limitations.md, that says:
This implies, although it's not written explicitly, that methods declared in interpreted code are emulated too, because it's not possible to declare methods on unnamed types. If the type you created stays in the interpreter, it works as expected. But if you pass it to compiled code (and There is no easy solution, because gomacro is a regular (although complex) Go program that uses reflection to create types, values, functions etc.: current Go |
What a pity ! Create a type with methods, instanciate and import it at runtime is my goal, but i believe that Go can do that. That's the first step to create Proxy instances from interfaces. So as it's impossible with actual Go state, i close this issue. |
If your goal is to implement pre-existing interfaces at runtime, that's actually easier.
Then you prepare a proxy struct that implements
At runtime, it's just a matter of creating a
For completeness, gomacro uses both techniques 1) and 2) internally. |
Hello,
I'd like to know where is the problem with this piece of code:
It prints «0» (zéro). So that's mean that with a type with methods when a value is created from this type, it don't have the methods.
The text was updated successfully, but these errors were encountered: