{"action":"created","issue":{"url":"https://api.github.com/repos/EMGroup/js-eden/issues/174","labels_url":"https://api.github.com/repos/EMGroup/js-eden/issues/174/labels{/name}","comments_url":"https://api.github.com/repos/EMGroup/js-eden/issues/174/comments","events_url":"https://api.github.com/repos/EMGroup/js-eden/issues/174/events","html_url":"https://github.com/EMGroup/js-eden/issues/174","id":120566946,"number":174,"title":"eval not parsing correctly","user":{"login":"ElizabethHudnott","id":8741304,"avatar_url":"https://avatars.githubusercontent.com/u/8741304?v=3","gravatar_id":"","url":"https://api.github.com/users/ElizabethHudnott","html_url":"https://github.com/ElizabethHudnott","followers_url":"https://api.github.com/users/ElizabethHudnott/followers","following_url":"https://api.github.com/users/ElizabethHudnott/following{/other_user}","gists_url":"https://api.github.com/users/ElizabethHudnott/gists{/gist_id}","starred_url":"https://api.github.com/users/ElizabethHudnott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElizabethHudnott/subscriptions","organizations_url":"https://api.github.com/users/ElizabethHudnott/orgs","repos_url":"https://api.github.com/users/ElizabethHudnott/repos","events_url":"https://api.github.com/users/ElizabethHudnott/events{/privacy}","received_events_url":"https://api.github.com/users/ElizabethHudnott/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-05T15:51:13Z","updated_at":"2015-12-06T18:33:32Z","closed_at":null,"body":"Example:\r\n\r\na = 2;\r\nb is a + 2;\r\nc is b + eval(b);\r\n"},"comment":{"url":"https://api.github.com/repos/EMGroup/js-eden/issues/comments/162334995","html_url":"https://github.com/EMGroup/js-eden/issues/174#issuecomment-162334995","issue_url":"https://api.github.com/repos/EMGroup/js-eden/issues/174","id":162334995,"user":{"login":"ElizabethHudnott","id":8741304,"avatar_url":"https://avatars.githubusercontent.com/u/8741304?v=3","gravatar_id":"","url":"https://api.github.com/users/ElizabethHudnott","html_url":"https://github.com/ElizabethHudnott","followers_url":"https://api.github.com/users/ElizabethHudnott/followers","following_url":"https://api.github.com/users/ElizabethHudnott/following{/other_user}","gists_url":"https://api.github.com/users/ElizabethHudnott/gists{/gist_id}","starred_url":"https://api.github.com/users/ElizabethHudnott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElizabethHudnott/subscriptions","organizations_url":"https://api.github.com/users/ElizabethHudnott/orgs","repos_url":"https://api.github.com/users/ElizabethHudnott/repos","events_url":"https://api.github.com/users/ElizabethHudnott/events{/privacy}","received_events_url":"https://api.github.com/users/ElizabethHudnott/received_events","type":"User","site_admin":false},"created_at":"2015-12-06T18:33:32Z","updated_at":"2015-12-06T18:33:32Z","body":"It's highlighted as a syntax error In the input window.  I don't have the old parser to hand right now, but it worked fine the last time I checked.\r\n\r\nIf you modify the syntax in the new parser then you will have to change a piece in the maintainer too, since it is re-parsed there.  Basically:\r\n\r\n(1) A dependency containing eval could occur inside a proc or an action, in which case the expression shouldn't be substituted with it's value until the proc or action is executed.  Hence it can't be evaluated at parsing time.\r\n\r\n(2) However, once the dependency has been stored in the symbol table the value of the expression must remain fixed (i.e. not subject to the usual subscribers/dependencies mechanism).  Also, evaluation happend in isolation then the bit inside the eval in the eden_definition would no longer make any sense (since it refers to the values of observables at definition time, which are not necessarily the same as the current values).\r\n\r\nTherefore, at definition time two things happen:\r\n\r\n(1) The expressions are evaluated.\r\n(2) The eden_definition gets re-parsed (not fully, but a simple regexp) and altered to substitute the values in place of the eval().  This makes the definition understandable when using the Observable List.  (tkeden also does this rewriting.)\r\n\r\nIn terms of how it works:\r\n\r\n(1) At parse time eval() simply gets replaced by a reference to an index into an object (basically an array with holes in it) which is a global property of the symbol table.\r\n(2) At definition time, the expressions get evaluated and populate those object keys.\r\n(3) When assignment, forget or redefinition happens then the relevant key-value pairs are deleted from the global object.\r\n\r\nRelevant files:\r\nOld Parser (jison files)\r\nOld Parser (printEvalIDs helper function in eden.js)\r\nMaintainer\r\n\r\nThis should be documented somewhere more permanent, since it isn't in Tim's thesis, It's a tkeden feature that was missing that I added later...\r\n"}}