{"action":"created","issue":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/8554","repository_url":"https://api.github.com/repos/nim-lang/Nim","labels_url":"https://api.github.com/repos/nim-lang/Nim/issues/8554/labels{/name}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/8554/comments","events_url":"https://api.github.com/repos/nim-lang/Nim/issues/8554/events","html_url":"https://github.com/nim-lang/Nim/pull/8554","id":348135156,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2NTU3NDky","number":8554,"title":"new macro for generic reflection: `extractGeneric(Foo2[float, string], 0) is float`","user":{"login":"timotheecour","id":2194784,"node_id":"MDQ6VXNlcjIxOTQ3ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2194784?v=4","gravatar_id":"","url":"https://api.github.com/users/timotheecour","html_url":"https://github.com/timotheecour","followers_url":"https://api.github.com/users/timotheecour/followers","following_url":"https://api.github.com/users/timotheecour/following{/other_user}","gists_url":"https://api.github.com/users/timotheecour/gists{/gist_id}","starred_url":"https://api.github.com/users/timotheecour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timotheecour/subscriptions","organizations_url":"https://api.github.com/users/timotheecour/orgs","repos_url":"https://api.github.com/users/timotheecour/repos","events_url":"https://api.github.com/users/timotheecour/events{/privacy}","received_events_url":"https://api.github.com/users/timotheecour/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-08-07T01:36:18Z","updated_at":"2018-12-04T07:02:01Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/nim-lang/Nim/pulls/8554","html_url":"https://github.com/nim-lang/Nim/pull/8554","diff_url":"https://github.com/nim-lang/Nim/pull/8554.diff","patch_url":"https://github.com/nim-lang/Nim/pull/8554.patch"},"body":"/cc @mratsim \r\n\r\n* this PR supports these:\r\n```nim\r\nFoo2[float, string].extractGeneric(0) is float\r\nFoo2[float, string].extractGeneric(-1) is Foo2\r\n```\r\n\r\n* **EDIT** fixes https://github.com/nim-lang/Nim/issues/6454\r\n* provides complete workaround for https://github.com/nim-lang/Nim/issues/8433\r\n* allows generic code needs to access generic params by index instead of by name\r\n\r\nin some contexts (IMO in most contexts), it's better to access generics by index rather than by name as mentioned by @mratsim here https://github.com/nim-lang/Nim/issues/8459#issuecomment-408359281\r\n> I'm also not super fan of this because the \"T\" or \"N\" seems to come from nowhere\r\n\r\nI also agree with that sentiment (see https://github.com/nim-lang/Nim/issues/8433#issuecomment-410357365), mainly because it avoids polluting scope with a generics's parameters.\r\n\r\na user writing `Foo.Bar` may be expecting `Bar(Foo) ` when in fact compiler interprets as accessing generic param Bar from generic type Foo.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/comments/443993410","html_url":"https://github.com/nim-lang/Nim/pull/8554#issuecomment-443993410","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/8554","id":443993410,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0Mzk5MzQxMA==","user":{"login":"timotheecour","id":2194784,"node_id":"MDQ6VXNlcjIxOTQ3ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2194784?v=4","gravatar_id":"","url":"https://api.github.com/users/timotheecour","html_url":"https://github.com/timotheecour","followers_url":"https://api.github.com/users/timotheecour/followers","following_url":"https://api.github.com/users/timotheecour/following{/other_user}","gists_url":"https://api.github.com/users/timotheecour/gists{/gist_id}","starred_url":"https://api.github.com/users/timotheecour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timotheecour/subscriptions","organizations_url":"https://api.github.com/users/timotheecour/orgs","repos_url":"https://api.github.com/users/timotheecour/repos","events_url":"https://api.github.com/users/timotheecour/events{/privacy}","received_events_url":"https://api.github.com/users/timotheecour/received_events","type":"User","site_admin":false},"created_at":"2018-12-04T07:02:01Z","updated_at":"2018-12-04T07:02:01Z","author_association":"COLLABORATOR","body":"ok I finally revived this PR and resolved conflicts; it's now hitting a regression unfortunately, see https://github.com/nim-lang/Nim/issues/9855\r\n\r\n@krux02 `normalizeType` is indeeed useful (and should hopefully turn into a PR); however, this PR has a different goal that your approach doesn't address (IIUC): generic way to access (as-is) head `Foo` and arguments `T0,T1,...` of a generic type `Foo[T1,T2,T2]`\r\ngiven type `Bar = Foo[T1,T2,T2]` I don't see how your approach get access to either `Foo` or, say, `T2`\r\n"}}
{"actor":{"display_login":"timotheecour"}}