{"action":"created","issue":{"url":"https://api.github.com/repos/smpallen99/xain/issues/5","repository_url":"https://api.github.com/repos/smpallen99/xain","labels_url":"https://api.github.com/repos/smpallen99/xain/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/smpallen99/xain/issues/5/comments","events_url":"https://api.github.com/repos/smpallen99/xain/issues/5/events","html_url":"https://github.com/smpallen99/xain/pull/5","id":156770642,"number":5,"title":"Use AST for markup generation instead of side-effects in ETS.","user":{"login":"romul","id":28540,"avatar_url":"https://avatars.githubusercontent.com/u/28540?v=3","gravatar_id":"","url":"https://api.github.com/users/romul","html_url":"https://github.com/romul","followers_url":"https://api.github.com/users/romul/followers","following_url":"https://api.github.com/users/romul/following{/other_user}","gists_url":"https://api.github.com/users/romul/gists{/gist_id}","starred_url":"https://api.github.com/users/romul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romul/subscriptions","organizations_url":"https://api.github.com/users/romul/orgs","repos_url":"https://api.github.com/users/romul/repos","events_url":"https://api.github.com/users/romul/events{/privacy}","received_events_url":"https://api.github.com/users/romul/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-25T14:50:08Z","updated_at":"2016-05-26T02:44:24Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/smpallen99/xain/pulls/5","html_url":"https://github.com/smpallen99/xain/pull/5","diff_url":"https://github.com/smpallen99/xain/pull/5.diff","patch_url":"https://github.com/smpallen99/xain/pull/5.patch"},"body":"Hi Steve,\r\nI thought about how Xain works and I came to the conclusion that use of ets is not required.\r\nPlease, take a look at implementation based on simple manipulations with AST. It converts body of `do` block to something like:\r\n``` elixir\r\nxain_buffer = []\r\nxain_buffer = [line1 | xain_buffer]\r\nxain_buffer = [line2 | xain_buffer]\r\nXain.join(xain_buffer)\r\n```\r\n\r\nThe implementation is API-compatible, i.e. all tests are passed without any change.\r\nAlthough there is one change: you couldn't use function with side-effects to produce html anymore. \r\nFor example:\r\n```elixir\r\nmarkup do\r\n  div(\"1\")\r\n  div(\"2\")\r\n  div(\"3\")\r\nend\r\n# => \"<div>1</div><div>2</div><div>3</div>\"\r\n\r\n# but\r\ntry_to_do_side_effects = fn -> \r\n  div(\"1\")\r\n  div(\"2\")\r\n  div(\"3\")\r\nend\r\ntry_to_do_side_effects.() # => \"<div>3</div>\"\r\n```\r\n\r\nThereby this change will require some refactoring in ex_admin to ditch side-effects. But I think this would be a very good changes and will improve readability and perspicuity of the code, b/c functional programming is hardly compatible with such the side-effects and encourage pure functions. So watching how a call of some function without any handling of its result produce some HTML in other place is kind of WAT.\r\n"},"comment":{"url":"https://api.github.com/repos/smpallen99/xain/issues/comments/221763633","html_url":"https://github.com/smpallen99/xain/pull/5#issuecomment-221763633","issue_url":"https://api.github.com/repos/smpallen99/xain/issues/5","id":221763633,"user":{"login":"smpallen99","id":891045,"avatar_url":"https://avatars.githubusercontent.com/u/891045?v=3","gravatar_id":"","url":"https://api.github.com/users/smpallen99","html_url":"https://github.com/smpallen99","followers_url":"https://api.github.com/users/smpallen99/followers","following_url":"https://api.github.com/users/smpallen99/following{/other_user}","gists_url":"https://api.github.com/users/smpallen99/gists{/gist_id}","starred_url":"https://api.github.com/users/smpallen99/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smpallen99/subscriptions","organizations_url":"https://api.github.com/users/smpallen99/orgs","repos_url":"https://api.github.com/users/smpallen99/repos","events_url":"https://api.github.com/users/smpallen99/events{/privacy}","received_events_url":"https://api.github.com/users/smpallen99/received_events","type":"User","site_admin":false},"created_at":"2016-05-26T02:44:24Z","updated_at":"2016-05-26T02:44:24Z","body":"I really like the idea. Agree, eliminating side affects is a good thing. I want to play around with it and try a few things..."}}
{"actor":{"display_login":"smpallen99"}}