{"action":"created","issue":{"url":"https://api.github.com/repos/bloomberg/bucklescript/issues/174","repository_url":"https://api.github.com/repos/bloomberg/bucklescript","labels_url":"https://api.github.com/repos/bloomberg/bucklescript/issues/174/labels{/name}","comments_url":"https://api.github.com/repos/bloomberg/bucklescript/issues/174/comments","events_url":"https://api.github.com/repos/bloomberg/bucklescript/issues/174/events","html_url":"https://github.com/bloomberg/bucklescript/issues/174","id":140275392,"number":174,"title":"object ffi design (taken from #123)","user":{"login":"bobzhang","id":747051,"avatar_url":"https://avatars.githubusercontent.com/u/747051?v=3","gravatar_id":"","url":"https://api.github.com/users/bobzhang","html_url":"https://github.com/bobzhang","followers_url":"https://api.github.com/users/bobzhang/followers","following_url":"https://api.github.com/users/bobzhang/following{/other_user}","gists_url":"https://api.github.com/users/bobzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/bobzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobzhang/subscriptions","organizations_url":"https://api.github.com/users/bobzhang/orgs","repos_url":"https://api.github.com/users/bobzhang/repos","events_url":"https://api.github.com/users/bobzhang/events{/privacy}","received_events_url":"https://api.github.com/users/bobzhang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/bloomberg/bucklescript/milestones/3","html_url":"https://github.com/bloomberg/bucklescript/milestones/future-","labels_url":"https://api.github.com/repos/bloomberg/bucklescript/milestones/3/labels","id":1639635,"number":3,"title":"future-","description":"","creator":{"login":"bobzhang","id":747051,"avatar_url":"https://avatars.githubusercontent.com/u/747051?v=3","gravatar_id":"","url":"https://api.github.com/users/bobzhang","html_url":"https://github.com/bobzhang","followers_url":"https://api.github.com/users/bobzhang/followers","following_url":"https://api.github.com/users/bobzhang/following{/other_user}","gists_url":"https://api.github.com/users/bobzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/bobzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobzhang/subscriptions","organizations_url":"https://api.github.com/users/bobzhang/orgs","repos_url":"https://api.github.com/users/bobzhang/repos","events_url":"https://api.github.com/users/bobzhang/events{/privacy}","received_events_url":"https://api.github.com/users/bobzhang/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":0,"state":"open","created_at":"2016-03-11T19:52:16Z","updated_at":"2016-03-14T13:29:50Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2016-03-11T19:51:24Z","updated_at":"2016-04-14T22:20:21Z","closed_at":null,"body":"#123 for the object part"},"comment":{"url":"https://api.github.com/repos/bloomberg/bucklescript/issues/comments/210179415","html_url":"https://github.com/bloomberg/bucklescript/issues/174#issuecomment-210179415","issue_url":"https://api.github.com/repos/bloomberg/bucklescript/issues/174","id":210179415,"user":{"login":"bobzhang","id":747051,"avatar_url":"https://avatars.githubusercontent.com/u/747051?v=3","gravatar_id":"","url":"https://api.github.com/users/bobzhang","html_url":"https://github.com/bobzhang","followers_url":"https://api.github.com/users/bobzhang/followers","following_url":"https://api.github.com/users/bobzhang/following{/other_user}","gists_url":"https://api.github.com/users/bobzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/bobzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobzhang/subscriptions","organizations_url":"https://api.github.com/users/bobzhang/orgs","repos_url":"https://api.github.com/users/bobzhang/repos","events_url":"https://api.github.com/users/bobzhang/events{/privacy}","received_events_url":"https://api.github.com/users/bobzhang/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T22:20:21Z","updated_at":"2016-04-14T22:20:21Z","body":"I have some better ideas. now since we introduce `_ Js_fn.t`, so that we can tell js uncurried function from ocaml curried function by the type, so we can do the same by introducing `'a Js.read` and `'a Js.write'\r\n\r\nso we only need to know the method dispatching is on js object or ocaml object (previously we also have to encode the arity) for an efficient FFI.\r\n\r\na bit convention would help\r\n\r\nproposal one:\r\n\r\n```ocaml\r\nx # length (* ocaml object --> compiled in ocaml style)\r\n\r\nx #_length |> Js.read (* js object )\r\n(* or we can do x#Length *)\r\nclass type js_obj = object\r\n   method _length : int Js.read\r\n   method hey : (int * unit) Js.fn\r\nend\r\n\r\n(* or *)\r\nclass type js_obj = < _length : int Js.read, hey : (int * unit) Js.fn >\r\n```\r\n\r\nnote that js_of_ocaml use `x ## length ` which is a syntax exntension and lift the type into phantom types, here `x#_length` is no more complex than `x##length` but it is vanilla ocaml (no complex syntax extension and complex types!)\r\n\r\nHaving ocaml style structural typing available for FFI would be a really exciting feature, @copy what do you think?\r\n"}}