{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/16580","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/16580/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/16580/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/16580/events","html_url":"https://github.com/JuliaLang/julia/pull/16580","id":156768424,"number":16580,"title":"WIP static dispatch for kwargs and structural fields","user":{"login":"carnaval","id":5307791,"avatar_url":"https://avatars.githubusercontent.com/u/5307791?v=3","gravatar_id":"","url":"https://api.github.com/users/carnaval","html_url":"https://github.com/carnaval","followers_url":"https://api.github.com/users/carnaval/followers","following_url":"https://api.github.com/users/carnaval/following{/other_user}","gists_url":"https://api.github.com/users/carnaval/gists{/gist_id}","starred_url":"https://api.github.com/users/carnaval/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carnaval/subscriptions","organizations_url":"https://api.github.com/users/carnaval/orgs","repos_url":"https://api.github.com/users/carnaval/repos","events_url":"https://api.github.com/users/carnaval/events{/privacy}","received_events_url":"https://api.github.com/users/carnaval/received_events","type":"User","site_admin":false},"labels":[{"id":171886684,"url":"https://api.github.com/repos/JuliaLang/julia/labels/types%20and%20dispatch","name":"types and dispatch","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/JuliaLang/julia/milestones/20","html_url":"https://github.com/JuliaLang/julia/milestone/20","labels_url":"https://api.github.com/repos/JuliaLang/julia/milestones/20/labels","id":1298021,"number":20,"title":"0.6.0","description":"","creator":{"login":"JeffBezanson","id":744556,"avatar_url":"https://avatars.githubusercontent.com/u/744556?v=3","gravatar_id":"","url":"https://api.github.com/users/JeffBezanson","html_url":"https://github.com/JeffBezanson","followers_url":"https://api.github.com/users/JeffBezanson/followers","following_url":"https://api.github.com/users/JeffBezanson/following{/other_user}","gists_url":"https://api.github.com/users/JeffBezanson/gists{/gist_id}","starred_url":"https://api.github.com/users/JeffBezanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeffBezanson/subscriptions","organizations_url":"https://api.github.com/users/JeffBezanson/orgs","repos_url":"https://api.github.com/users/JeffBezanson/repos","events_url":"https://api.github.com/users/JeffBezanson/events{/privacy}","received_events_url":"https://api.github.com/users/JeffBezanson/received_events","type":"User","site_admin":false},"open_issues":153,"closed_issues":66,"state":"open","created_at":"2015-09-09T16:35:16Z","updated_at":"2016-12-15T19:32:25Z","due_on":"2017-02-28T00:00:00Z","closed_at":null},"comments":12,"created_at":"2016-05-25T14:41:39Z","updated_at":"2016-12-15T21:58:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/16580","html_url":"https://github.com/JuliaLang/julia/pull/16580","diff_url":"https://github.com/JuliaLang/julia/pull/16580.diff","patch_url":"https://github.com/JuliaLang/julia/pull/16580.patch"},"body":"I tried a couple approaches for kwargs but this one I like.\nIt introduces a structural named-fields counterpart to tuple types (unimaginatively called `Struct`). You can make a `Struct(x = 1.0, y = 2.0)` and it has type `Struct{(:x,:y),Tuple{Float,Float}}` with fields `x` and `y`.\n\nThere is a couple functions to merge or diff them and it uses that as the basis for kwargs splatting and unpacking.\n\nThis PR is not ready yet and is up here mostly to discuss the implications. The problematic one are probably over-specialization and the use of staged functions in the implementation (as always).\n\nAssuming we want this, here are a few points I'm wondering about :\n- Should we aim to merge those things with `Tuple` so that we have only one kind of structural type. We'd get dispatch-on-kwargs for \"free\" (== retrofit all code that touches tuple types ... hem). This is probably a long term question and keeping them separate is a decent first step in that direction anyway.\n- Should they be covariant ? I'm guessing yes.\n- Should they have vararg forms ? I'm guessing yes too, so you could match on \"at least those fields with those types\"\n- Should they have an optional-field form ? Like `{x::Int, y?::Int}` that has `{x::Int,y::Int}` and `{x::Int}` as subtypes. I tink this is necessary if we want to express our current kwarg semantics using only normal dispatch and avoid generating a lot of methods.\n- Should we always sort fields ? For now `Struct` types take ordering into account but the kwarg lowering/merging/diffing always keeps them sorted to avoid generating a specialization for every permutation.\n\nOther than that, it currently seem to work when used as a replacement for our current kwarg lowering and we get specialization, inlining, inference etc.\nGoing forward with this we can probably remove a bit of the `kwfunc` business but for now I only did minimal integration.\n\nI feel that the `Struct` type is interesting in itself anyway.\n"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/267456613","html_url":"https://github.com/JuliaLang/julia/pull/16580#issuecomment-267456613","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/16580","id":267456613,"user":{"login":"JeffBezanson","id":744556,"avatar_url":"https://avatars.githubusercontent.com/u/744556?v=3","gravatar_id":"","url":"https://api.github.com/users/JeffBezanson","html_url":"https://github.com/JeffBezanson","followers_url":"https://api.github.com/users/JeffBezanson/followers","following_url":"https://api.github.com/users/JeffBezanson/following{/other_user}","gists_url":"https://api.github.com/users/JeffBezanson/gists{/gist_id}","starred_url":"https://api.github.com/users/JeffBezanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeffBezanson/subscriptions","organizations_url":"https://api.github.com/users/JeffBezanson/orgs","repos_url":"https://api.github.com/users/JeffBezanson/repos","events_url":"https://api.github.com/users/JeffBezanson/events{/privacy}","received_events_url":"https://api.github.com/users/JeffBezanson/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T21:58:53Z","updated_at":"2016-12-15T21:58:53Z","body":"I had a slightly crazy idea along these lines the other day. We could add the ability to annotate elements of a Tuple type with names, like so:\r\n\r\n```\r\nTuple{Int, Named{:a, Int}, Named{:b, String}}\r\n```\r\n\r\nA tuple with this type would behave exactly like a `Tuple{Int,Int,String}`, except you could also do `x.a` and `x.b` to get the second and third elements. The `Named` pseudo-type is troubling, and I'd rather avoid repeating the mistake of `Vararg`, but this type has some interesting properties:\r\n\r\n1. It's largely compatible with tuples and the changes for it would be pretty minimal.\r\n2. It provides all the features of NamedTuples.\r\n3. It allows both positional and named entries, potentially describing a full argument list including both positional and keyword arguments.\r\n\r\nUnfortunately this doesn't seem to serve up a solution for keyword arguments on a silver platter; subsetting keyword args is still a problem, and the fact that this type is inherently ordered doesn't seem to help either. But it could be an interesting design to consider."}}
{"actor":{"display_login":"JeffBezanson"}}