{"action":"created","issue":{"url":"https://api.github.com/repos/brson/mir2wasm/issues/33","repository_url":"https://api.github.com/repos/brson/mir2wasm","labels_url":"https://api.github.com/repos/brson/mir2wasm/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/brson/mir2wasm/issues/33/comments","events_url":"https://api.github.com/repos/brson/mir2wasm/issues/33/events","html_url":"https://github.com/brson/mir2wasm/issues/33","id":167975612,"number":33,"title":"WASM function imports","user":{"login":"lqd","id":247183,"avatar_url":"https://avatars.githubusercontent.com/u/247183?v=3","gravatar_id":"","url":"https://api.github.com/users/lqd","html_url":"https://github.com/lqd","followers_url":"https://api.github.com/users/lqd/followers","following_url":"https://api.github.com/users/lqd/following{/other_user}","gists_url":"https://api.github.com/users/lqd/gists{/gist_id}","starred_url":"https://api.github.com/users/lqd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lqd/subscriptions","organizations_url":"https://api.github.com/users/lqd/orgs","repos_url":"https://api.github.com/users/lqd/repos","events_url":"https://api.github.com/users/lqd/events{/privacy}","received_events_url":"https://api.github.com/users/lqd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-27T22:54:26Z","updated_at":"2016-07-27T23:07:40Z","closed_at":null,"body":"Related to #29 is the issue of importing wasm functions from other wasm modules (or the environment, say, a JS function). What form should it take in our rust code ?\r\n\r\nSome more info https://github.com/WebAssembly/design/blob/master/Modules.md#imports\r\nExample https://github.com/WebAssembly/testsuite/blob/master/imports.wast#L2\r\n\r\nMaking it work similarly to the current FFI machinery would make sense, and this would look good I think:\r\n```rust\r\n#[link(name=\"spectest\")]\r\nextern {\r\n    fn print(i: i32);\r\n}\r\n```\r\n\r\nHowever, and this might be special treatment for the `spectest` module (probably @kripken can shed some light on this topic), it seems in this case — as seen in the linked example — the `print` function is overloaded. This might be a special case because exports are apparently required to have a unique name, IIUC meaning one might not be able to produce the same exports as the `spectest` module provides.\r\n\r\nIf this is to be supported — which is itself an interesting question, especially since printing is right now our \"only\" way to test — we might need to roll our own custom attribute à la:\r\n```rust\r\nextern {\r\n    #[wasm_import(module=\"specttest\", name=\"print\")]\r\n    fn print_i32(i: i32);\r\n\r\n    #[wasm_import(module=\"specttest\", name=\"print\")]\r\n    fn print_i64(i: i64);\r\n}\r\n```\r\nThere may be other attributes or language features more closely matching the semantics/requirements ? Maybe `#[link_args]` could be of use, etc. \r\n\r\n@brson and @eholk what do you think ?"},"comment":{"url":"https://api.github.com/repos/brson/mir2wasm/issues/comments/235748846","html_url":"https://github.com/brson/mir2wasm/issues/33#issuecomment-235748846","issue_url":"https://api.github.com/repos/brson/mir2wasm/issues/33","id":235748846,"user":{"login":"brson","id":147214,"avatar_url":"https://avatars.githubusercontent.com/u/147214?v=3","gravatar_id":"","url":"https://api.github.com/users/brson","html_url":"https://github.com/brson","followers_url":"https://api.github.com/users/brson/followers","following_url":"https://api.github.com/users/brson/following{/other_user}","gists_url":"https://api.github.com/users/brson/gists{/gist_id}","starred_url":"https://api.github.com/users/brson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brson/subscriptions","organizations_url":"https://api.github.com/users/brson/orgs","repos_url":"https://api.github.com/users/brson/repos","events_url":"https://api.github.com/users/brson/events{/privacy}","received_events_url":"https://api.github.com/users/brson/received_events","type":"User","site_admin":false},"created_at":"2016-07-27T23:07:39Z","updated_at":"2016-07-27T23:07:39Z","body":"@eddyb's syntax looks right to me. It ultimately *must* work exactly like any other FFI import so that 'normal' Rust code can be compiled to wasm."}}
{"actor":{"display_login":"brson"}}