{"action":"created","issue":{"url":"https://api.github.com/repos/hylang/hy/issues/899","labels_url":"https://api.github.com/repos/hylang/hy/issues/899/labels{/name}","comments_url":"https://api.github.com/repos/hylang/hy/issues/899/comments","events_url":"https://api.github.com/repos/hylang/hy/issues/899/events","html_url":"https://github.com/hylang/hy/issues/899","id":101308559,"number":899,"title":"rename defclass to class","user":{"login":"gilch","id":3346292,"avatar_url":"https://avatars.githubusercontent.com/u/3346292?v=3","gravatar_id":"","url":"https://api.github.com/users/gilch","html_url":"https://github.com/gilch","followers_url":"https://api.github.com/users/gilch/followers","following_url":"https://api.github.com/users/gilch/following{/other_user}","gists_url":"https://api.github.com/users/gilch/gists{/gist_id}","starred_url":"https://api.github.com/users/gilch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gilch/subscriptions","organizations_url":"https://api.github.com/users/gilch/orgs","repos_url":"https://api.github.com/users/gilch/repos","events_url":"https://api.github.com/users/gilch/events{/privacy}","received_events_url":"https://api.github.com/users/gilch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/hylang/hy/milestones/8","html_url":"https://github.com/hylang/hy/milestones/Grand%20Language%20Cleanup","labels_url":"https://api.github.com/repos/hylang/hy/milestones/8/labels","id":1224085,"number":8,"title":"Grand Language Cleanup","description":"There are a couple of workarounds in the language that have bugs and issues that are hard (or even impossible) to solve, because of being tied to Python semantics. Instead of trying to be something the language isn't, these should be cleaned up, and replaced with something more pythonic - and thus less buggy from a pythonist PoV. To ease migration, a compatibility shim may be provided.\r\n\r\nLets track these here!","creator":{"login":"algernon","id":17243,"avatar_url":"https://avatars.githubusercontent.com/u/17243?v=3","gravatar_id":"","url":"https://api.github.com/users/algernon","html_url":"https://github.com/algernon","followers_url":"https://api.github.com/users/algernon/followers","following_url":"https://api.github.com/users/algernon/following{/other_user}","gists_url":"https://api.github.com/users/algernon/gists{/gist_id}","starred_url":"https://api.github.com/users/algernon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algernon/subscriptions","organizations_url":"https://api.github.com/users/algernon/orgs","repos_url":"https://api.github.com/users/algernon/repos","events_url":"https://api.github.com/users/algernon/events{/privacy}","received_events_url":"https://api.github.com/users/algernon/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":15,"state":"open","created_at":"2015-07-24T13:55:39Z","updated_at":"2015-08-17T06:20:22Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2015-08-16T23:23:48Z","updated_at":"2015-08-17T14:35:52Z","closed_at":null,"body":"`class` is a reserved word in Python, and so is already reserved in Hy,\r\n```Hy\r\n=> (def class \"Hy\")\r\n  File \"<input>\", line 1, column 6\r\n\r\n  (def class \"Hy\")\r\n       ^----^\r\nHyTypeError: Can't assign to a builtin: `class'\r\n```\r\nbut doesn't do anything useful. \r\n```Hy\r\n=> (class)\r\nclass()\r\nTraceback (most recent call last):\r\n  File \"<input>\", line 1, in <module>\r\nNameError: name 'class' is not defined\r\n=> class\r\nclass\r\nTraceback (most recent call last):\r\n  File \"<input>\", line 1, in <module>\r\nNameError: name 'class' is not defined\r\n```\r\nAnd `class` is shorter to type."},"comment":{"url":"https://api.github.com/repos/hylang/hy/issues/comments/131842655","html_url":"https://github.com/hylang/hy/issues/899#issuecomment-131842655","issue_url":"https://api.github.com/repos/hylang/hy/issues/899","id":131842655,"user":{"login":"zackmdavis","id":1076988,"avatar_url":"https://avatars.githubusercontent.com/u/1076988?v=3","gravatar_id":"","url":"https://api.github.com/users/zackmdavis","html_url":"https://github.com/zackmdavis","followers_url":"https://api.github.com/users/zackmdavis/followers","following_url":"https://api.github.com/users/zackmdavis/following{/other_user}","gists_url":"https://api.github.com/users/zackmdavis/gists{/gist_id}","starred_url":"https://api.github.com/users/zackmdavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zackmdavis/subscriptions","organizations_url":"https://api.github.com/users/zackmdavis/orgs","repos_url":"https://api.github.com/users/zackmdavis/repos","events_url":"https://api.github.com/users/zackmdavis/events{/privacy}","received_events_url":"https://api.github.com/users/zackmdavis/received_events","type":"User","site_admin":false},"created_at":"2015-08-17T14:35:52Z","updated_at":"2015-08-17T14:35:52Z","body":"I think maintaining the analogy to `def`, `defn`, and `defmacro` that Algernon mentions is more important than saving three characters or minimizing the number of keywords, even unfortunate keywords that don't do anything. (Hey, JavaScript gets by with [a few of those](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Future_reserved_keywords), right?&mdash;although maybe that's not the best role model.) But speaking of which&mdash;\r\n\r\n> class is a reserved word in Python, and so is already reserved in Hy,\r\n\r\n[We do that](https://github.com/hylang/hy/blob/ead65b646/hy/compiler.py#L85-L86), but you know, I don't think we *need* to do that. By bypassing Python's parser and constructing `ast` nodes directly, Hy has been known to create Python ASTs that aren't legal Python in the respect of using illegal names; that's why, for example, you could name a function `set!` even before [the bang-mangling patch](https://github.com/hylang/hy/pull/885) landed.\r\n```\r\nzmd@ExpectedReturn:~$ hy --spy  # last released version, no '!' mangling\r\nhy 0.11.0 using CPython(default) 3.4.0 on Linux\r\n=> (defn set! [])\r\ndef set!(): # bad Python (even though `--spy` didn't notice)\r\n    pass\r\n```\r\nA simple experiment suggests we'd likely be able to do the same for `class` and other Python keywords that we don't need as Hy keywords&mdash;\r\n```\r\nin [1]: import ast; from ast import *\r\nin [2]: ast.dump(ast.parse(\"foo = 1\"))\r\nOut[2]: \"Module(body=[Assign(targets=[Name(id='foo', ctx=Store())], value=Num(n=1))])\"\r\n\r\n# We can't parse the use of `class` as a variable name ...\r\nin [3]: ast.dump(ast.parse(\"class = 1\"))  File \"<unknown>\", line 1\r\n    class = 1\r\n          ^\r\nSyntaxError: invalid syntax\r\n\r\n# But no one objects if we construct the corresponding AST ourselves.\r\nin [4]: ast.dump(Module(body=[Assign(targets=[Name(id='class', ctx=Store())], value=Num(n=1))]))\r\nOut[4]: \"Module(body=[Assign(targets=[Name(id='class', ctx=Store())], value=Num(n=1))])\"\r\n```"}}