{"action":"created","issue":{"url":"https://api.github.com/repos/jarcane/heresy/issues/37","labels_url":"https://api.github.com/repos/jarcane/heresy/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/jarcane/heresy/issues/37/comments","events_url":"https://api.github.com/repos/jarcane/heresy/issues/37/events","html_url":"https://github.com/jarcane/heresy/issues/37","id":119727462,"number":37,"title":"Bindings in state notation cannot self-reference","user":{"login":"jarcane","id":8036258,"avatar_url":"https://avatars.githubusercontent.com/u/8036258?v=3","gravatar_id":"","url":"https://api.github.com/users/jarcane","html_url":"https://github.com/jarcane","followers_url":"https://api.github.com/users/jarcane/followers","following_url":"https://api.github.com/users/jarcane/following{/other_user}","gists_url":"https://api.github.com/users/jarcane/gists{/gist_id}","starred_url":"https://api.github.com/users/jarcane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarcane/subscriptions","organizations_url":"https://api.github.com/users/jarcane/orgs","repos_url":"https://api.github.com/users/jarcane/repos","events_url":"https://api.github.com/users/jarcane/events{/privacy}","received_events_url":"https://api.github.com/users/jarcane/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jarcane/heresy/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-12-01T14:26:57Z","updated_at":"2015-12-02T13:07:06Z","closed_at":null,"body":"The following example will not work: \r\n\r\n```\r\n#lang heresy\r\n\r\n(do> (:= x 5)\r\n     (:= (x) x (* x x))\r\n     (return x))\r\n```\r\nAttempting to reassign a value self-referentially produces an error:\r\n```\r\nDocuments\\GitHub\\heresy\\lib\\things.rkt:81:20: lst: undefined;\r\n cannot use before initialization\r\n```\r\nLine referenced: https://github.com/jarcane/heresy/blob/master/lib/things.rkt#L81\r\n\r\nAt a guess and tinkering with it, it seems the trouble possibly arises from the mutual references to `this` and `lst` inside the `(make-thing ...)` function. Swapping the order of their definitions causes an error reference to `this` instead.\r\n\r\n Possibly though there may be an issue with `(#%app)` as a previous error triggered there instead but with the same message. "},"comment":{"url":"https://api.github.com/repos/jarcane/heresy/issues/comments/161285605","html_url":"https://github.com/jarcane/heresy/issues/37#issuecomment-161285605","issue_url":"https://api.github.com/repos/jarcane/heresy/issues/37","id":161285605,"user":{"login":"jeapostrophe","id":232698,"avatar_url":"https://avatars.githubusercontent.com/u/232698?v=3","gravatar_id":"","url":"https://api.github.com/users/jeapostrophe","html_url":"https://github.com/jeapostrophe","followers_url":"https://api.github.com/users/jeapostrophe/followers","following_url":"https://api.github.com/users/jeapostrophe/following{/other_user}","gists_url":"https://api.github.com/users/jeapostrophe/gists{/gist_id}","starred_url":"https://api.github.com/users/jeapostrophe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeapostrophe/subscriptions","organizations_url":"https://api.github.com/users/jeapostrophe/orgs","repos_url":"https://api.github.com/users/jeapostrophe/repos","events_url":"https://api.github.com/users/jeapostrophe/events{/privacy}","received_events_url":"https://api.github.com/users/jeapostrophe/received_events","type":"User","site_admin":false},"created_at":"2015-12-02T13:07:06Z","updated_at":"2015-12-02T13:07:06Z","body":"This gets the right answer and I believe is what you want:\r\n\r\n```racket\r\n(def macroset :=\r\n  [(:= (name ...) var value)\r\n   (fn (s)\r\n     (thing extends s\r\n            (var (let ([name (s (quote name))] ...)\r\n                   value))))]\r\n  [(:= var value)\r\n   (fn (s) (thing extends s (var value)))])\r\n```"}}