{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/24990","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/24990/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/24990/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/24990/events","html_url":"https://github.com/JuliaLang/julia/pull/24990","id":280587731,"number":24990,"title":"RFC: curry underscore arguments to create anonymous functions","user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars3.githubusercontent.com/u/2913679?v=4","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"labels":[{"id":210700,"url":"https://api.github.com/repos/JuliaLang/julia/labels/decision","name":"decision","color":"F08000","default":false},{"id":294535982,"url":"https://api.github.com/repos/JuliaLang/julia/labels/needs%20docs","name":"needs docs","color":"d4c5f9","default":false},{"id":421481488,"url":"https://api.github.com/repos/JuliaLang/julia/labels/needs%20news","name":"needs news","color":"d4c5f9","default":false},{"id":294535960,"url":"https://api.github.com/repos/JuliaLang/julia/labels/needs%20tests","name":"needs tests","color":"5319e7","default":false},{"id":163368715,"url":"https://api.github.com/repos/JuliaLang/julia/labels/parser","name":"parser","color":"bfdadc","default":false},{"id":688843543,"url":"https://api.github.com/repos/JuliaLang/julia/labels/triage","name":"triage","color":"f00040","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":26,"created_at":"2017-12-08T19:10:10Z","updated_at":"2017-12-10T01:45:04Z","closed_at":null,"author_association":"OWNER","pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/24990","html_url":"https://github.com/JuliaLang/julia/pull/24990","diff_url":"https://github.com/JuliaLang/julia/pull/24990.diff","patch_url":"https://github.com/JuliaLang/julia/pull/24990.patch"},"body":"This PR addresses #554, #5571, and #22710 by \"currying\" underscores in function calls like `f(_,y)` into anonymous function expressions `x -> f(x,y)`.  (Note that `_.foo` works and turns into `x -> x.foo` since it is equivalent to a `getfield` call, and `_[i]` works and turns into `x -> x[i]`, since it is equivalent to a `getindex(_,i)` call.)\r\n\r\nThis will help us get rid of functions like `equalto` (#23812) or `occursin` (#24967), is useful for \"destructuring\" as discussed in #22710, and should generally be convenient in lots of cases to avoid having to explicitly do `x -> f(x,y)`.\r\n\r\nSome simplifying design decisions that I made:\r\n\r\n* The currying is \"tight\", i.e. it only converts the immediately surrounding function call into a lambda.   So, e.g. `f(g(_,y))` is equivalent to `f(x -> g(x,y))`.   (Note that something like `find(!(_ in c), y)` will work fine, because the `!` operator works on functions; you can also use `_ ∉ c`.)  Any other rule seems hard to make comprehensible and consistent.\r\n\r\n* Only a single underscore is allowed.  `f(_,_)` throws an error: this case seems ambiguous to me (do you want `x -> f(x,x)` or `x,y -> f(x,y)`?), so it seemed better to punt on this for now.  We can always add a meaning for multiple underscores later.\r\n\r\nThe implementation is pretty trivial.  If people are in favor, I will add\r\n- [ ] Tests\r\n- [ ] Documentation"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/350518991","html_url":"https://github.com/JuliaLang/julia/pull/24990#issuecomment-350518991","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/24990","id":350518991,"user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars3.githubusercontent.com/u/2913679?v=4","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"created_at":"2017-12-10T01:45:04Z","updated_at":"2017-12-10T01:45:04Z","author_association":"OWNER","body":"(\"Loose\" binding for a selected set of operators like `+` could also be achieved on top of this PR by defining function-composition methods for them, analogous to what we did for `!` in #17155.  But I'm doubt defining lots of `function + number` and similar methods one by one is a good idea.)"}}
{"actor":{"display_login":"stevengj"}}