{"action":"created","issue":{"url":"https://api.github.com/repos/TyOverby/ares/issues/7","labels_url":"https://api.github.com/repos/TyOverby/ares/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/TyOverby/ares/issues/7/comments","events_url":"https://api.github.com/repos/TyOverby/ares/issues/7/events","html_url":"https://github.com/TyOverby/ares/pull/7","id":108737176,"number":7,"title":"Add Context as the main API layer","user":{"login":"TyOverby","id":573215,"avatar_url":"https://avatars.githubusercontent.com/u/573215?v=3","gravatar_id":"","url":"https://api.github.com/users/TyOverby","html_url":"https://github.com/TyOverby","followers_url":"https://api.github.com/users/TyOverby/followers","following_url":"https://api.github.com/users/TyOverby/following{/other_user}","gists_url":"https://api.github.com/users/TyOverby/gists{/gist_id}","starred_url":"https://api.github.com/users/TyOverby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TyOverby/subscriptions","organizations_url":"https://api.github.com/users/TyOverby/orgs","repos_url":"https://api.github.com/users/TyOverby/repos","events_url":"https://api.github.com/users/TyOverby/events{/privacy}","received_events_url":"https://api.github.com/users/TyOverby/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-28T20:11:58Z","updated_at":"2015-10-01T07:32:02Z","closed_at":"2015-10-01T07:32:02Z","pull_request":{"url":"https://api.github.com/repos/TyOverby/ares/pulls/7","html_url":"https://github.com/TyOverby/ares/pull/7","diff_url":"https://github.com/TyOverby/ares/pull/7.diff","patch_url":"https://github.com/TyOverby/ares/pull/7.patch"},"body":"The \"Context\" is the main API level that the user will interact with.  Instead of passing `Env` around all the time, we'll instead pass around Contexts.  There are two types of Contexts: Regular `Context` and a `LoadedContext`.  \r\n\r\n1. The `Context` will allow the library user to read and write into the global environment but not evaluate anything.\r\n2. The `LoadedContext` is \"loaded\" with a mutable reference to some rust state that the library user wants to have mutated by the evaluation of lisp code.\r\n\r\nThe ultimate goal is to have something like this be possible:\r\n\r\n```rust\r\nlet mut ctx = Context::new();\r\nlet mut counter = 0;\r\nctx.env().add_function(\"increment-counter\", |ctx, _args| {\r\n    *ctx.state = ctx.state + 1; // increment the counter.\r\n});\r\n\r\n{\r\n    let loaded = ctx.load(&mut counter);\r\n    for _ in 0 .. 5 {\r\n        loaded.call_global(\"increment-counter\", vec![]);\r\n    }\r\n}\r\n\r\nassert_eq!(counter, 5);\r\n\r\n```\r\n\r\n@bwo : I'm nowhere near done, but I'd like you to be updated and get feedback as soon as possible."},"comment":{"url":"https://api.github.com/repos/TyOverby/ares/issues/comments/144643615","html_url":"https://github.com/TyOverby/ares/pull/7#issuecomment-144643615","issue_url":"https://api.github.com/repos/TyOverby/ares/issues/7","id":144643615,"user":{"login":"TyOverby","id":573215,"avatar_url":"https://avatars.githubusercontent.com/u/573215?v=3","gravatar_id":"","url":"https://api.github.com/users/TyOverby","html_url":"https://github.com/TyOverby","followers_url":"https://api.github.com/users/TyOverby/followers","following_url":"https://api.github.com/users/TyOverby/following{/other_user}","gists_url":"https://api.github.com/users/TyOverby/gists{/gist_id}","starred_url":"https://api.github.com/users/TyOverby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TyOverby/subscriptions","organizations_url":"https://api.github.com/users/TyOverby/orgs","repos_url":"https://api.github.com/users/TyOverby/repos","events_url":"https://api.github.com/users/TyOverby/events{/privacy}","received_events_url":"https://api.github.com/users/TyOverby/received_events","type":"User","site_admin":false},"created_at":"2015-10-01T07:32:02Z","updated_at":"2015-10-01T07:32:02Z","body":"Closing in favor of #14 "}}