-
Notifications
You must be signed in to change notification settings - Fork 951
support //go:wasmimport or a similarly named alias for imported functions #3147
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
Comments
fwiw, TinyGo also supports |
@james-lawrence forked an issue for your above comment so it doesn't end up lost. This example can be made now and syntax changed later (among the other ones) #3154 |
I missed the fact that Long term, I'd also like to change the behavior of |
#3165 was merged into |
This was completed as part of release |
Let's support
//go:wasmimport
or a similarly named alias for imported functions. This would be an alias to//export
, so that existing code can work, but much more intuitive. By being more intuitive, new users have a better experience, and we have less load on issues as well less angst on support.Background
Currently, users need to add the keyword
//export
in order to import a function (ex from the wasm host).ex.
This is very unintuitive and provides a bad first time experience for TinyGo users. It also occupies many issues and in doing so steals time from folks contributing support. A couple examples are #3000 and #455, but there are many more occurrences than this, including my personal first experience.
As far as I understand the history from @aykevl,
I would argue that this can be true, but jargon that doesn't match is also more confusing than re-use of some C related jargon in Go. Many Go developers won't think through like this, hence the continual support questions.
More background could be that Go didn't have an
import
keyword. For example, In Go, you need to define a .s file then use aCallImport
instruction there. The point remains that it also uses the word import not export for this.https://github.com/golang/go/blob/master/src/syscall/js/js_js.s#L63-L65
However, if you look at the latest on Go, golang/go#38248, it appears
//go:wasmimport
would be used, not//export
, for importing functions.The text was updated successfully, but these errors were encountered: