{"action":"created","issue":{"url":"https://api.github.com/repos/alehander42/gara/issues/17","repository_url":"https://api.github.com/repos/alehander42/gara","labels_url":"https://api.github.com/repos/alehander42/gara/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/alehander42/gara/issues/17/comments","events_url":"https://api.github.com/repos/alehander42/gara/issues/17/events","html_url":"https://github.com/alehander42/gara/issues/17","id":386458826,"node_id":"MDU6SXNzdWUzODY0NTg4MjY=","number":17,"title":"Suggestion: Leverages Nim's multiple dispatch to make it extensible","user":{"login":"geohuz","id":730770,"node_id":"MDQ6VXNlcjczMDc3MA==","avatar_url":"https://avatars1.githubusercontent.com/u/730770?v=4","gravatar_id":"","url":"https://api.github.com/users/geohuz","html_url":"https://github.com/geohuz","followers_url":"https://api.github.com/users/geohuz/followers","following_url":"https://api.github.com/users/geohuz/following{/other_user}","gists_url":"https://api.github.com/users/geohuz/gists{/gist_id}","starred_url":"https://api.github.com/users/geohuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geohuz/subscriptions","organizations_url":"https://api.github.com/users/geohuz/orgs","repos_url":"https://api.github.com/users/geohuz/repos","events_url":"https://api.github.com/users/geohuz/events{/privacy}","received_events_url":"https://api.github.com/users/geohuz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-01T13:31:33Z","updated_at":"2018-12-01T16:59:54Z","closed_at":null,"author_association":"NONE","body":"Example from Julia's patterndispatch:\r\n```\r\n@pattern f(x) =  x\r\n@pattern f(2) = 42\r\n\r\nprintln([f(x) for x=1:4])\r\nprints\r\n\r\n[1, 42, 3, 4]\r\n```\r\n\r\nactually the @pattern expands to the following code:\r\n```\r\nconst f = (args...)->dispatch(args...)\r\n\r\n# ---- Pattern methods: ----\r\n# f(x,)\r\nfunction match1(x)\t#  test_examples.jl, line 6:\r\n    x\r\nend\r\n\r\n# f(2,)\r\nfunction match2()\t#  test_examples.jl, line 7:\r\n    42\r\nend\r\n\r\n# ---- Dispatch methods: ----\r\nfunction dispatch(x_1::Any)\r\n    match1(x_1)\r\nend\r\n\r\nfunction dispatch(x_1::Int64)\r\n    if is(x_1, 2)\r\n        match2()\r\n    else\r\n        match1(x_1)\r\n    end\r\nend\r\n```\r\n\r\nYou can see it is a really powerful idea which decoupling the dispatch logic from giant if/else block and new logic can be dynamically added. I would say it's a general pattern of multi-method which called predicate dispatch: https://en.wikipedia.org/wiki/Predicate_dispatch\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/alehander42/gara/issues/comments/443440473","html_url":"https://github.com/alehander42/gara/issues/17#issuecomment-443440473","issue_url":"https://api.github.com/repos/alehander42/gara/issues/17","id":443440473,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzQ0MDQ3Mw==","user":{"login":"alehander42","id":830715,"node_id":"MDQ6VXNlcjgzMDcxNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/830715?v=4","gravatar_id":"","url":"https://api.github.com/users/alehander42","html_url":"https://github.com/alehander42","followers_url":"https://api.github.com/users/alehander42/followers","following_url":"https://api.github.com/users/alehander42/following{/other_user}","gists_url":"https://api.github.com/users/alehander42/gists{/gist_id}","starred_url":"https://api.github.com/users/alehander42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alehander42/subscriptions","organizations_url":"https://api.github.com/users/alehander42/orgs","repos_url":"https://api.github.com/users/alehander42/repos","events_url":"https://api.github.com/users/alehander42/events{/privacy}","received_events_url":"https://api.github.com/users/alehander42/received_events","type":"User","site_admin":false},"created_at":"2018-12-01T16:59:54Z","updated_at":"2018-12-01T16:59:54Z","author_association":"OWNER","body":"Yeah, this is pretty cool: I like it a lot in Elixir.\r\n\r\nHowever, this is an independent feature: we can have both the match branch structure and matchable overloads.\r\n\r\nMatchable overloads would look a bit like this: https://github.com/alehander42/poly \r\n\r\n"}}
{"actor":{"display_login":"alehander42"}}