{"action":"created","issue":{"url":"https://api.github.com/repos/sctb/lumen/issues/20","labels_url":"https://api.github.com/repos/sctb/lumen/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/sctb/lumen/issues/20/comments","events_url":"https://api.github.com/repos/sctb/lumen/issues/20/events","html_url":"https://github.com/sctb/lumen/issues/20","id":110397942,"number":20,"title":"On Lua hosts, a fn created via `define` cannot be called at any point above the definition","user":{"login":"laarc","id":13237912,"avatar_url":"https://avatars.githubusercontent.com/u/13237912?v=3","gravatar_id":"","url":"https://api.github.com/users/laarc","html_url":"https://github.com/laarc","followers_url":"https://api.github.com/users/laarc/followers","following_url":"https://api.github.com/users/laarc/following{/other_user}","gists_url":"https://api.github.com/users/laarc/gists{/gist_id}","starred_url":"https://api.github.com/users/laarc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laarc/subscriptions","organizations_url":"https://api.github.com/users/laarc/orgs","repos_url":"https://api.github.com/users/laarc/repos","events_url":"https://api.github.com/users/laarc/events{/privacy}","received_events_url":"https://api.github.com/users/laarc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-08T08:32:59Z","updated_at":"2015-10-08T16:54:11Z","closed_at":null,"body":"\r\nLua gets an error:\r\n\r\n```\r\n$ LUMEN_HOST=luajit bin/lumen -e \"(do (define-global f (x) (g x)) (define g (x) (+ x 1)) (f 21))\"\r\nerror: attempt to call global 'g' (a nil value)\r\n```\r\n\r\nNode works as expected:\r\n\r\n```\r\n$ LUMEN_HOST=node bin/lumen -e \"(do (define-global f (x) (g x)) (define g (x) (+ x 1)) (f 21))\"\r\n22\r\n```\r\n\r\nThere might not be an easy fix for this, but it'd be very nice.  For example PR #17 had to move the definition of `run` to the top of the file in order for the `remap` function to call it.\r\n\r\nThe `ac.l` file I'm writing should look as visually similar to 3.1's `ac.scm` as possible.  But the very first definition in `ac.scm` is the `ac` function, which then calls a bunch of functions that are defined later in the file.\r\n\r\nWithout this feature, I'm currently forced to use `define-global` for all functions in my `ac.l` file.\r\n\r\n(To be clear, this isn't a very important issue. I'm fine with using `define-global` for everything.  I figured I'd mention it though.)\r\n"},"comment":{"url":"https://api.github.com/repos/sctb/lumen/issues/comments/146620429","html_url":"https://github.com/sctb/lumen/issues/20#issuecomment-146620429","issue_url":"https://api.github.com/repos/sctb/lumen/issues/20","id":146620429,"user":{"login":"sctb","id":41661,"avatar_url":"https://avatars.githubusercontent.com/u/41661?v=3","gravatar_id":"","url":"https://api.github.com/users/sctb","html_url":"https://github.com/sctb","followers_url":"https://api.github.com/users/sctb/followers","following_url":"https://api.github.com/users/sctb/following{/other_user}","gists_url":"https://api.github.com/users/sctb/gists{/gist_id}","starred_url":"https://api.github.com/users/sctb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sctb/subscriptions","organizations_url":"https://api.github.com/users/sctb/orgs","repos_url":"https://api.github.com/users/sctb/repos","events_url":"https://api.github.com/users/sctb/events{/privacy}","received_events_url":"https://api.github.com/users/sctb/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T16:54:10Z","updated_at":"2015-10-08T16:54:10Z","body":"I decided to leave this behavior up to the host implementation. Lua happens to be quite a bit stricter about its definitions (this also comes up in recursive definitions). "}}