{"action":"created","issue":{"url":"https://api.github.com/repos/openscad/openscad/issues/1199","labels_url":"https://api.github.com/repos/openscad/openscad/issues/1199/labels{/name}","comments_url":"https://api.github.com/repos/openscad/openscad/issues/1199/comments","events_url":"https://api.github.com/repos/openscad/openscad/issues/1199/events","html_url":"https://github.com/openscad/openscad/issues/1199","id":56170887,"number":1199,"title":"Feature request: Function scope and variables","user":{"login":"oysteinkrog","id":653040,"avatar_url":"https://avatars.githubusercontent.com/u/653040?v=3","gravatar_id":"","url":"https://api.github.com/users/oysteinkrog","html_url":"https://github.com/oysteinkrog","followers_url":"https://api.github.com/users/oysteinkrog/followers","following_url":"https://api.github.com/users/oysteinkrog/following{/other_user}","gists_url":"https://api.github.com/users/oysteinkrog/gists{/gist_id}","starred_url":"https://api.github.com/users/oysteinkrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oysteinkrog/subscriptions","organizations_url":"https://api.github.com/users/oysteinkrog/orgs","repos_url":"https://api.github.com/users/oysteinkrog/repos","events_url":"https://api.github.com/users/oysteinkrog/events{/privacy}","received_events_url":"https://api.github.com/users/oysteinkrog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-01T17:42:47Z","updated_at":"2015-02-01T17:53:25Z","closed_at":null,"body":"Currently it is possible to use variables in a function with this syntax (using let):\r\n\r\n```\r\nfunction func(arg1) = \r\nlet(var1 = 1,     \r\n     var2 = arg1)\r\nvar1+var2;\r\n```\r\n\r\nIt would be nice if we could use the same syntax that is used in the rest of the language, e.g something like this:\r\n\r\n```\r\nfunction func(arg1) = \r\n{\r\n     var1 = 1;\r\n     var2 = arg1;\r\n     var1+var2;\r\n}\r\n```\r\n\r\nIn the above version the return value is simply the last statement, an explicit return is also an option:\r\n\r\n```\r\nfunction func(arg1) = \r\n{\r\n     var1 = 1;\r\n     var2 = arg1;\r\n     return var1+var2;\r\n}\r\n```\r\nI know there are other issues/OEP's that cover this (e.g. OEP3), but this is a specific request for this small change (and only this).\r\nFor more complex functions this is sorely needed. Having to use let() seems unnecessary to me, especially considering the recent removal of assign().\r\nFor newcomers it would be a large improvement if the same syntax that is used everywhere else also worked inside functions. \r\n\r\n\r\n<bountysource-plugin>\r\n\r\n---\r\nWant to back this issue? **[Place a bounty on it!](https://www.bountysource.com/issues/8201377-feature-request-function-scope-and-variables?utm_campaign=plugin&utm_content=tracker%2F52063&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F52063&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/openscad/openscad/issues/comments/72375170","html_url":"https://github.com/openscad/openscad/issues/1199#issuecomment-72375170","issue_url":"https://api.github.com/repos/openscad/openscad/issues/1199","id":72375170,"user":{"login":"kintel","id":186094,"avatar_url":"https://avatars.githubusercontent.com/u/186094?v=3","gravatar_id":"","url":"https://api.github.com/users/kintel","html_url":"https://github.com/kintel","followers_url":"https://api.github.com/users/kintel/followers","following_url":"https://api.github.com/users/kintel/following{/other_user}","gists_url":"https://api.github.com/users/kintel/gists{/gist_id}","starred_url":"https://api.github.com/users/kintel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kintel/subscriptions","organizations_url":"https://api.github.com/users/kintel/orgs","repos_url":"https://api.github.com/users/kintel/repos","events_url":"https://api.github.com/users/kintel/events{/privacy}","received_events_url":"https://api.github.com/users/kintel/received_events","type":"User","site_admin":false},"created_at":"2015-02-01T17:53:25Z","updated_at":"2015-02-01T17:53:25Z","body":"As this is directly mappable to a cascade of let() expressions, it should be doable.\r\nNeed to discuss a bit, but I _think_ I agree."}}