-
Notifications
You must be signed in to change notification settings - Fork 570
compiler: go:linkname support method #1152
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
Conversation
Can you give an example when this would be necessary? In general, it seem to me that this would encourage monkey patching, which is often fragile and is a source of difficult to debug issues. |
Yes, it is difficult to implement complete type conversion. example https://github.com/goplusjs/reflectx/blob/main/name_js.go#L17 this package provide https://github.com/goplus/igop Interpreter Go/Go+ code for web. but this project build for github.com/goplusjs/gopherjs only run on go1.16. |
Actually, I think I may have misunderstood the intent of this PR. It allows you to make an unexported method from a third-party package available to your code, right? It does not attempt to replace method implementation in the third-party package with your own? If so, my concern about monkey-patching is not valid. Another question: does the upstream Go compiler support this style of |
it can call other package unexport method
go compiler support go:linkname func symbol ( func and mehtod pkg.func/pkg.type.method/pkg.(*type).method ) |
That makes sense, thanks. I see you are still updating this PR. Please let me know when it is ready for a detailed review, and I'll try to do it without too much delay (hopefully) 😀 Edit: I see you've just marked it ready a few hours ago, never mind then! I'll try to take a close look at it soon. |
@nevkontakte add tests and reset commit for this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay, here's the first round of comments. I think overall this looks good, but there are a couple of places that (I think) could be simplified.
Co-authored-by: Nevkontakte <nevkontakte@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good to me!
And thank you again for yet another contribution to GopherJS! ☺ |
syntax
go:linkname pkg.type.method
go:linkname pkg.(*type).method
type convert
demo