{"action":"created","issue":{"url":"https://api.github.com/repos/scala-native/scala-native/issues/897","repository_url":"https://api.github.com/repos/scala-native/scala-native","labels_url":"https://api.github.com/repos/scala-native/scala-native/issues/897/labels{/name}","comments_url":"https://api.github.com/repos/scala-native/scala-native/issues/897/comments","events_url":"https://api.github.com/repos/scala-native/scala-native/issues/897/events","html_url":"https://github.com/scala-native/scala-native/issues/897","id":240999042,"number":897,"title":"Proposal: Interop 2.0","user":{"login":"densh","id":320966,"avatar_url":"https://avatars3.githubusercontent.com/u/320966?v=3","gravatar_id":"","url":"https://api.github.com/users/densh","html_url":"https://github.com/densh","followers_url":"https://api.github.com/users/densh/followers","following_url":"https://api.github.com/users/densh/following{/other_user}","gists_url":"https://api.github.com/users/densh/gists{/gist_id}","starred_url":"https://api.github.com/users/densh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/densh/subscriptions","organizations_url":"https://api.github.com/users/densh/orgs","repos_url":"https://api.github.com/users/densh/repos","events_url":"https://api.github.com/users/densh/events{/privacy}","received_events_url":"https://api.github.com/users/densh/received_events","type":"User","site_admin":false},"labels":[{"id":478231182,"url":"https://api.github.com/repos/scala-native/scala-native/labels/feature","name":"feature","color":"1d76db","default":false},{"id":371735845,"url":"https://api.github.com/repos/scala-native/scala-native/labels/interop","name":"interop","color":"c2e0c6","default":false},{"id":396743299,"url":"https://api.github.com/repos/scala-native/scala-native/labels/semantics","name":"semantics","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/scala-native/scala-native/milestones/11","html_url":"https://github.com/scala-native/scala-native/milestone/11","labels_url":"https://api.github.com/repos/scala-native/scala-native/milestones/11/labels","id":2532948,"number":11,"title":"0.4","description":"","creator":{"login":"densh","id":320966,"avatar_url":"https://avatars3.githubusercontent.com/u/320966?v=3","gravatar_id":"","url":"https://api.github.com/users/densh","html_url":"https://github.com/densh","followers_url":"https://api.github.com/users/densh/followers","following_url":"https://api.github.com/users/densh/following{/other_user}","gists_url":"https://api.github.com/users/densh/gists{/gist_id}","starred_url":"https://api.github.com/users/densh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/densh/subscriptions","organizations_url":"https://api.github.com/users/densh/orgs","repos_url":"https://api.github.com/users/densh/repos","events_url":"https://api.github.com/users/densh/events{/privacy}","received_events_url":"https://api.github.com/users/densh/received_events","type":"User","site_admin":false},"open_issues":49,"closed_issues":0,"state":"open","created_at":"2017-05-20T14:32:24Z","updated_at":"2017-07-09T13:19:15Z","due_on":"2017-08-10T07:00:00Z","closed_at":null},"comments":18,"created_at":"2017-07-06T15:38:48Z","updated_at":"2017-07-12T17:50:37Z","closed_at":null,"body":"# Interop 2.0\r\n\r\nScala Native 0.4 is going to contain a revamped interop layer based on feedback we've gather so far. Here are some rough overview of the updated features:\r\n\r\n## Extern members\r\n\r\n* `@extern object` no more.\r\n\r\n* `def $name(..$args): $T = extern` can appear in any class, module or trait. \r\n\r\n* `val $name: $T = extern` can appear in any class, module or trait.\r\n\r\n* `var $name: $T = extern` can appear in any class, module or trait.\r\n\r\n* Extern members must provide explicit return type (enforced by the compiler.)\r\n\r\n* Binds to native symbols with `$name` or to a custom name given via `@name(\"...\")`.\r\n\r\n* `@link(\"...\")` can appear on any class, module, trait, method or field. If the given definition is reachable at link-time, linker would link with the corresponding native library automatically.\r\n\r\n## Structs\r\n\r\n* `CStructN` no more.\r\n\r\n* `@struct class $name(...$params) extends ..$traits { ..$members }`\r\n\r\n* Can have arbitrary number of method and fields, both mutable and immutable.\r\n\r\n* Can extend traits.\r\n\r\n* Can be a case-class.\r\n\r\n* Implicitly stack-allocated.\r\n \r\n  ```\r\n  @struct class Point(var x: Int, var y: Int)\r\n\r\n  val point = new Point(10, 20) // implicitly allocates a stack slot\r\n  point.x = 20                  // updates stack-allocated memory\r\n  point.y = 30\r\n  ```\r\n\r\n* Resides on stack, inside managed objects, inside managed and fixed arrays and other structs in unboxed form.\r\n\r\n  ```\r\n  val array = new Array[Point](10) \r\n  array(0).x = 10                  // updates array-allocated memory\r\n  array(0).y = 10\r\n  ```\r\n\r\n* Boxes whenever passed to generic erased context (i.e. upcast to Any.)\r\n\r\n* Transperantly copied by-value across different storage locations.\r\n\r\n* Passing them to extern methods respects C ABI.\r\n\r\n## Fixed-size arrays\r\n \r\n* `CArray` no more. **TODO:** needs a new name.\r\n\r\n* Has a standard literal syntax for initialization. \r\n\r\n* New type for fixed-size arrays.\r\n\r\n* Implicitly stack allocated for local variables.\r\n\r\n* Resides on stack, inside managed objects, inside managed and fixed arrays and other structs in unboxed form.\r\n\r\n* Boxes whenever passed to generic erased context (i.e. upcast to Any.)\r\n\r\n* Transperantly copied by-value across different storage locations.\r\n\r\n* Passing them to extern methods respects C ABI.\r\n\r\n## Pointers\r\n\r\n* `Ptr[T]` with most operations unchanged.\r\n\r\n* `_N` methods are gone, new implicit conversion `implicit def inner[T <: AnyRef](ptr: Ptr[T]): T`\r\n  together with extra checks in the compiler to make sure that it only applies to structs. This\r\n  enables calling methods and reading fields directly through pointer:\r\n\r\n  ```\r\n  var points: Ptr[Point] = stackalloc[Point](100)\r\n  points.x = 10 // updates points(0).x\r\n  points.y = 20 // updates points(0).y\r\n  points += 1\r\n  points.x = 30 // updates points(1).x\r\n  points.y = 40 // updates points(1).y\r\n  ```\r\n\r\n* Boxes whenever passed to generic context but remains unboxed inside of the arrays. \r\n\r\n## Function pointers\r\n\r\n* CFunctionPtr as before, with known bugs fixed.\r\n\r\n## C numeric types\r\n\r\n* Type aliases in the `scalanative.native.*` as before.\r\n\r\n## Unsigned numeric types\r\n\r\n* They become `@struct` classes instead of scalac-style value classes. This enables storing them in unboxed form inside of the arrays.\r\n\r\n* Otherwise unchanged as before\r\n\r\n## Varargs\r\n\r\n* Similar to what we've had before, only `CVararg` becomes a first-class object and can be abstracted over. \r\n\r\n## Generic intrinsic methods \r\n\r\n* Methods that take `scalanative.native.Tag` can be abstracted over in generic way by providing correct implicits. This may incur performance overhead due to boxing. Specialized code remains to be the recommended option for performance-sensitive code.\r\n\r\n## TODO\r\n\r\n* TODO: `@union` with similar semantics to `@struct`\r\n"},"comment":{"url":"https://api.github.com/repos/scala-native/scala-native/issues/comments/314846019","html_url":"https://github.com/scala-native/scala-native/issues/897#issuecomment-314846019","issue_url":"https://api.github.com/repos/scala-native/scala-native/issues/897","id":314846019,"user":{"login":"ekrich","id":933058,"avatar_url":"https://avatars2.githubusercontent.com/u/933058?v=3","gravatar_id":"","url":"https://api.github.com/users/ekrich","html_url":"https://github.com/ekrich","followers_url":"https://api.github.com/users/ekrich/followers","following_url":"https://api.github.com/users/ekrich/following{/other_user}","gists_url":"https://api.github.com/users/ekrich/gists{/gist_id}","starred_url":"https://api.github.com/users/ekrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekrich/subscriptions","organizations_url":"https://api.github.com/users/ekrich/orgs","repos_url":"https://api.github.com/users/ekrich/repos","events_url":"https://api.github.com/users/ekrich/events{/privacy}","received_events_url":"https://api.github.com/users/ekrich/received_events","type":"User","site_admin":false},"created_at":"2017-07-12T17:50:37Z","updated_at":"2017-07-12T17:50:37Z","body":"Here is an issue I submitted to `utest` where Scala Native is not super friendly to the library. This may help influence design decisions . https://github.com/lihaoyi/utest/issues/118"}}
{"actor":{"display_login":"ekrich"}}