{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/5571","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/5571/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/5571/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/5571/events","html_url":"https://github.com/JuliaLang/julia/issues/5571","id":26355302,"number":5571,"title":"Function chaining","user":{"login":"shelakel","id":1434829,"avatar_url":"https://avatars.githubusercontent.com/u/1434829?v=3","gravatar_id":"","url":"https://api.github.com/users/shelakel","html_url":"https://github.com/shelakel","followers_url":"https://api.github.com/users/shelakel/followers","following_url":"https://api.github.com/users/shelakel/following{/other_user}","gists_url":"https://api.github.com/users/shelakel/gists{/gist_id}","starred_url":"https://api.github.com/users/shelakel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shelakel/subscriptions","organizations_url":"https://api.github.com/users/shelakel/orgs","repos_url":"https://api.github.com/users/shelakel/repos","events_url":"https://api.github.com/users/shelakel/events{/privacy}","received_events_url":"https://api.github.com/users/shelakel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":63,"created_at":"2014-01-27T14:16:55Z","updated_at":"2015-06-10T01:37:05Z","closed_at":null,"body":"Would it be possible to allow calling any function on Any so that the value is passed to the function as the first parameter and the parameters passed to the function call on the value is added afterwards?\r\nex.\r\n\r\n    sum(a::Int, b::Int) -> a + b\r\n\r\n    a = 1\r\n    sum(1, 2) # = 3\r\n    a.sum(2) # = 3 or\r\n    1.sum(2) # = 3\r\n\r\nIs it possible to indicate in a deterministic way what a function will return in order to avoid run time exceptions?"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/110553869","html_url":"https://github.com/JuliaLang/julia/issues/5571#issuecomment-110553869","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/5571","id":110553869,"user":{"login":"H-225","id":1348560,"avatar_url":"https://avatars.githubusercontent.com/u/1348560?v=3","gravatar_id":"","url":"https://api.github.com/users/H-225","html_url":"https://github.com/H-225","followers_url":"https://api.github.com/users/H-225/followers","following_url":"https://api.github.com/users/H-225/following{/other_user}","gists_url":"https://api.github.com/users/H-225/gists{/gist_id}","starred_url":"https://api.github.com/users/H-225/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/H-225/subscriptions","organizations_url":"https://api.github.com/users/H-225/orgs","repos_url":"https://api.github.com/users/H-225/repos","events_url":"https://api.github.com/users/H-225/events{/privacy}","received_events_url":"https://api.github.com/users/H-225/received_events","type":"User","site_admin":false},"created_at":"2015-06-10T01:37:05Z","updated_at":"2015-06-10T01:37:05Z","body":"@tkelman @oxinabox \r\nI have yet to find a clear reason why it should not be included in the language, or indeed in the \"core\" packages.\r\nPersonally, I think making `|>` a macro might be the answer.\r\nSomething _like_ this perhaps? (I'm not a master Julia programmer!)\r\n```\r\nmacro (|>) (x, y::Union(Symbol, Expr))\r\n           if isa(y, Symbol)\r\n               y = Expr(:call, y)\r\n           end\r\n           push!(y.args, x)\r\n           return eval(y)\r\n       end\r\n```\r\nUnder Julia v0.3.9, I was unable to define it twice -- once with a symbol, and once with an expression; my [limited] understanding of `Union` is that there is performance hit from using it, so I'm guessing that would be something to rectify in my toy example code.\r\n\r\nOf course, there is a problem with the use syntax for this.\r\nFor example, to run the equivalent of `log(2, 10)`, you have to write `@|> 10 log(2)`, which isn't desirable here.\r\nMy understanding is that you'd have to be able to somehow mark functions/macros as \"infixable\", as it were, such that you could then write it thus: `10 |> log(2)`. (Correct if wrong!)\r\nContrived example, I know. I can't think of a good one right now! =)\r\n\r\nIt's also worth pointing out one area I have not covered in my example...\r\nSo e.g:\r\n```\r\njulia> for e in ([1:10], [11:20] |> zip) println(e) end\r\n(1,11)\r\n(2,12)\r\n(3,13)\r\n(4,14)\r\n(5,15)\r\n(6,16)\r\n(7,17)\r\n(8,18)\r\n(9,19)\r\n(10,20)\r\n```\r\nAgain - contrived example, but hopefully you get the point!\r\nI did some fiddling, but as of writing this I was unable to fathom how to implement that, myself."}}