{"action":"created","issue":{"url":"https://api.github.com/repos/inf3rno/function/issues/1","labels_url":"https://api.github.com/repos/inf3rno/function/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/inf3rno/function/issues/1/comments","events_url":"https://api.github.com/repos/inf3rno/function/issues/1/events","html_url":"https://github.com/inf3rno/function/issues/1","id":108456403,"number":1,"title":"domain model","user":{"login":"inf3rno","id":408911,"avatar_url":"https://avatars.githubusercontent.com/u/408911?v=3","gravatar_id":"","url":"https://api.github.com/users/inf3rno","html_url":"https://github.com/inf3rno","followers_url":"https://api.github.com/users/inf3rno/followers","following_url":"https://api.github.com/users/inf3rno/following{/other_user}","gists_url":"https://api.github.com/users/inf3rno/gists{/gist_id}","starred_url":"https://api.github.com/users/inf3rno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inf3rno/subscriptions","organizations_url":"https://api.github.com/users/inf3rno/orgs","repos_url":"https://api.github.com/users/inf3rno/repos","events_url":"https://api.github.com/users/inf3rno/events{/privacy}","received_events_url":"https://api.github.com/users/inf3rno/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/inf3rno/function/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"inf3rno","id":408911,"avatar_url":"https://avatars.githubusercontent.com/u/408911?v=3","gravatar_id":"","url":"https://api.github.com/users/inf3rno","html_url":"https://github.com/inf3rno","followers_url":"https://api.github.com/users/inf3rno/followers","following_url":"https://api.github.com/users/inf3rno/following{/other_user}","gists_url":"https://api.github.com/users/inf3rno/gists{/gist_id}","starred_url":"https://api.github.com/users/inf3rno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inf3rno/subscriptions","organizations_url":"https://api.github.com/users/inf3rno/orgs","repos_url":"https://api.github.com/users/inf3rno/repos","events_url":"https://api.github.com/users/inf3rno/events{/privacy}","received_events_url":"https://api.github.com/users/inf3rno/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2015-09-26T11:10:28Z","updated_at":"2015-10-05T13:41:05Z","closed_at":null,"body":"https://github.com/inf3rno/query/issues/2\r\n\r\nthe base of the query descriptions and async data flow graphs are the same: we need to describe function blocks and function calls in a stream-pipe syntax. so what we will get is the simplest async AST ever, since it only contains functions calls and function block definitions, which build only on function calls (we don't need value expressions, because we can solve that part in js/json).\r\n\r\na simple sync function\r\n```\r\nfunction f (a,b,c){\r\n    return [x,y,z];\r\n}\r\n```\r\n\r\nwhat we really have here is something like this:\r\n```\r\nscope(\r\n    function f \r\n        stack(with(context)(a,b,c){\r\n            return [x,y,z]\r\n        })\r\n)\r\n```\r\n\r\nwe can replace the context and the function parameters and return values, with the usage of variables. since it is transformed by a compiler this is not an issue.\r\n\r\n```\r\nscope(\r\n    function f stack({\r\n        var this = with(context);\r\n        var a = in(0);\r\n        var b = in(1);\r\n        var c = in(2);\r\n        var x = out(0);\r\n        var y = out(1);\r\n        var z = out(2);\r\n    })\r\n)\r\n```\r\nwe can set values this way:\r\n\r\n```\r\n        var c = in(2);\r\n        var x = out(0);\r\n        pipe(c, x);\r\n```\r\nby sync code the effect is instant by async code, it has to wait, so we can add something like \r\n\r\n```\r\n        wait(x);\r\n```\r\nwhich waits for c to get a value.\r\nofc we can use multiple parameters, for example\r\n```\r\nwait (x,y,z)\r\nreturn ()\r\n```\r\nreturn is important here, because it helps to loosely couple multiple function calls. so we don't have to burn into function definitions, which other functions can call them.\r\nthe return returns on every output port simultaneously. so if we don't wait every value, then it is a syntax error. this is funny, because we don't have a guarantee that we calls wait with every output. so this is error prone. that's why we need to add wait(*) to the return function. the return is important, because it destroys the stack.\r\n\r\n```\r\ncomp1.out -> pipe -> comp2.in ({s = stack(comp2), s.in -> pipe -> s.out}) comp2.out -> pipe -> ...\r\n```\r\nso the outside function calls are about `pipe (x.out -> y.in)` while the inside function definitions are about `pipe (c.in -> c.out)`.\r\n\r\nscope is a strange thing in js, it is about injecting variables from outside to the definitions. this is something like \r\n```\r\ncomp = define({s = stack(), [s.in, v1, v2] -> pipe -> s.out}, v1, v2, ...)\r\n```\r\nso the comp will return an arra with the params and the v1, v2 outside variables.\r\n\r\n```\r\nv1 = ...\r\nv2 = ...\r\nexport(v1)\r\nexport(v2)\r\ncomp = {s = stack(), v1 = import(), v2 = import(), [s.in,v1,v2] -> pipe -> s.out}\r\n```\r\n\r\nwe can spare the export part if we want, but that will complicate things.\r\nthis import() sugar syntax is about injecting variables to function definitions\r\nif a function definition is a function call either we can do it this way:\r\n\r\n```\r\ncomp = define({s = stack(), i = import(), [s.in, i.1, i.2] -> pipe -> s.out}, export(v1), export(v2), ...)\r\n```\r\nhmm so in general terms exports are output ports and imports input ports as well. the only difference that we inject them, so they are not defined by define.\r\n```\r\ncomp = define({s = stack(), [in(s.1), in(1), in(2)] -> pipe -> s.out}, out(v1), out(v2), ...)\r\n```\r\n\r\n```\r\ncomp = define({s = stack(), [in(s.1), in(1), in(2)] -> pipe -> s.out}, out(v1), out(v2), ...)\r\n```\r\nthe block can be an array of function calls\r\n\r\n```\r\ncomp = define([\r\n    var c = scope();\r\n    var s = stack();\r\n    var i = arguments(s);\r\n    var o = return(s);\r\n    pipe([i.1, c.1, c.2], [o.1, o.2, o.3]);\r\n], out(v1), out(v2), ...)\r\n```"},"comment":{"url":"https://api.github.com/repos/inf3rno/function/issues/comments/145530815","html_url":"https://github.com/inf3rno/function/issues/1#issuecomment-145530815","issue_url":"https://api.github.com/repos/inf3rno/function/issues/1","id":145530815,"user":{"login":"inf3rno","id":408911,"avatar_url":"https://avatars.githubusercontent.com/u/408911?v=3","gravatar_id":"","url":"https://api.github.com/users/inf3rno","html_url":"https://github.com/inf3rno","followers_url":"https://api.github.com/users/inf3rno/followers","following_url":"https://api.github.com/users/inf3rno/following{/other_user}","gists_url":"https://api.github.com/users/inf3rno/gists{/gist_id}","starred_url":"https://api.github.com/users/inf3rno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inf3rno/subscriptions","organizations_url":"https://api.github.com/users/inf3rno/orgs","repos_url":"https://api.github.com/users/inf3rno/repos","events_url":"https://api.github.com/users/inf3rno/events{/privacy}","received_events_url":"https://api.github.com/users/inf3rno/received_events","type":"User","site_admin":false},"created_at":"2015-10-05T13:41:05Z","updated_at":"2015-10-05T13:41:05Z","body":"currently babel supports es7 more or less, so we could use that with node and in browser. http://stackoverflow.com/questions/30773756/is-it-okay-to-use-babel-node-in-production I assume async and object.observe is not necessary there. i have to try it out. if there are workarounds, then it would be great."}}