{"action":"created","issue":{"url":"https://api.github.com/repos/ziglang/zig/issues/1099","repository_url":"https://api.github.com/repos/ziglang/zig","labels_url":"https://api.github.com/repos/ziglang/zig/issues/1099/labels{/name}","comments_url":"https://api.github.com/repos/ziglang/zig/issues/1099/comments","events_url":"https://api.github.com/repos/ziglang/zig/issues/1099/events","html_url":"https://github.com/ziglang/zig/issues/1099","id":331597642,"node_id":"MDU6SXNzdWUzMzE1OTc2NDI=","number":1099,"title":"Tags","user":{"login":"BraedonWooding","id":22880786,"node_id":"MDQ6VXNlcjIyODgwNzg2","avatar_url":"https://avatars1.githubusercontent.com/u/22880786?v=4","gravatar_id":"","url":"https://api.github.com/users/BraedonWooding","html_url":"https://github.com/BraedonWooding","followers_url":"https://api.github.com/users/BraedonWooding/followers","following_url":"https://api.github.com/users/BraedonWooding/following{/other_user}","gists_url":"https://api.github.com/users/BraedonWooding/gists{/gist_id}","starred_url":"https://api.github.com/users/BraedonWooding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BraedonWooding/subscriptions","organizations_url":"https://api.github.com/users/BraedonWooding/orgs","repos_url":"https://api.github.com/users/BraedonWooding/repos","events_url":"https://api.github.com/users/BraedonWooding/events{/privacy}","received_events_url":"https://api.github.com/users/BraedonWooding/received_events","type":"User","site_admin":false},"labels":[{"id":693800736,"node_id":"MDU6TGFiZWw2OTM4MDA3MzY=","url":"https://api.github.com/repos/ziglang/zig/labels/proposal","name":"proposal","color":"aaefdc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ziglang/zig/milestones/6","html_url":"https://github.com/ziglang/zig/milestone/6","labels_url":"https://api.github.com/repos/ziglang/zig/milestones/6/labels","id":3149533,"node_id":"MDk6TWlsZXN0b25lMzE0OTUzMw==","number":6,"title":"0.4.0","description":"Accept and resolve these issues, reject, or postpone them before releasing 0.4.0.","creator":{"login":"andrewrk","id":106511,"node_id":"MDQ6VXNlcjEwNjUxMQ==","avatar_url":"https://avatars0.githubusercontent.com/u/106511?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewrk","html_url":"https://github.com/andrewrk","followers_url":"https://api.github.com/users/andrewrk/followers","following_url":"https://api.github.com/users/andrewrk/following{/other_user}","gists_url":"https://api.github.com/users/andrewrk/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewrk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewrk/subscriptions","organizations_url":"https://api.github.com/users/andrewrk/orgs","repos_url":"https://api.github.com/users/andrewrk/repos","events_url":"https://api.github.com/users/andrewrk/events{/privacy}","received_events_url":"https://api.github.com/users/andrewrk/received_events","type":"User","site_admin":false},"open_issues":210,"closed_issues":15,"state":"open","created_at":"2018-02-28T05:37:00Z","updated_at":"2018-06-12T16:26:32Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2018-06-12T13:52:40Z","updated_at":"2018-06-12T21:43:49Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"> This was discussed originally [here](https://github.com/Hejsil/zig-clap/issues/8#issuecomment-381637825), and elsewhere :).\r\n\r\n### Motivation\r\n\r\nI've been looking at implementing lambda functions (by first making all functions anonymous) but I feel like I should begin with something a little easier as to help me understand the codebase; I've recently had need for reflection metadata in a codegen which generates getters/setters (amongst other things) for structs in relation to a stack based system for a markup language that translates to a IR/bytecode representation, anyways it would be nice to allow users to disable/hide this generation with a hide tag (as well as customise such as link getters/setters to other functions).  Amongst other tags, regardless this would be a nice feature I'm sure many authors would enjoy.  I'll be looking towards implementing this, this upcoming weekend but I wanted to gather opinion on syntax :).\r\n\r\n## Proposal\r\n\r\nThe original proposal was this;\r\n```C\r\nconst Foo = struct {\r\n    x: u32 @(\"anything\") @(bar()),\r\n};\r\n\r\nfn bar() i32 {\r\n    return 1234;\r\n}\r\n```\r\n\r\nHowever this proposes a problem of how one would access the tags, since they aren't purely the same type; in the majority of cases (specifically I can't think of a case where this isn't true) you just want a string tag not a 'boolean' tag since in reality having something like `@(true)` is meaningless compared to `@(\"Hide\")` so I propose the following restriction; all tags are just strings and `@(\"X\")` is replaced with `@tag(\"X\")` this makes it a little simpler to read and a lot simpler to actually handle.\r\n```C\r\nconst Foo = struct {\r\n  x: u32 @tag(\"A\") @tag(\"B\"),\r\n};\r\n```\r\nAlso tags will be able to be applied to almost anything that is globally scoped that is functions (global), structs (note: variables can't have tags) having something like;\r\n```C\r\nfn X() void @tag(\"MyFunc\") {\r\n    ...\r\n}\r\n```\r\n\r\nYou would access it like;\r\n```C\r\n// For Struct\r\nfor (@typeInfo(Foo).Struct.fields) |field| {\r\n    for (field.Tags) |tag| {\r\n       // Do whatever with tag\r\n    }\r\n}\r\n\r\n// For function\r\nfor (@typeInfo(X).Fn) |tag| {\r\n    // Do whatever with tag\r\n}\r\n```\r\n\r\nYou could also query all objects that have a certain tag like;\r\n```C\r\ncomptime const query = @withTag(\"A\"); // returning typeInfo\r\n```\r\nNow this would look through each typeInfo available returning a static array of all that have it, however we could also maintain a map of each tag to a list of typeinfo making this much much more efficient but increase the size of the running compiler (I feel a valid tradeoff).\r\n\r\n## Actual Changes\r\n\r\n- Syntax Change: allow `@tag(...)` after types in global 'objects' (functions, structs), currently only `@tag(...)` but probably add syntactically support for any attribute (in terms of format `@<...>(<...>)` but lexically only support tag, this would allow us to expand it later for other attributes if wanted\r\n- Builtin.zig change (autogen that is); add 'tags' field to StructField, and Fn that is a string slice (u8 const)\r\n- Add `@tag(tagName: []const u8)` and `@withTag(tagName: []const u8)->[]const @import(\"builtin\").TypeInfo`\r\n   - Note: `@tag` is not grouped under attributes perhaps but rather is separate as it doesn't have a return type"},"comment":{"url":"https://api.github.com/repos/ziglang/zig/issues/comments/396744503","html_url":"https://github.com/ziglang/zig/issues/1099#issuecomment-396744503","issue_url":"https://api.github.com/repos/ziglang/zig/issues/1099","id":396744503,"node_id":"MDEyOklzc3VlQ29tbWVudDM5Njc0NDUwMw==","user":{"login":"monouser7dig","id":26345163,"node_id":"MDQ6VXNlcjI2MzQ1MTYz","avatar_url":"https://avatars2.githubusercontent.com/u/26345163?v=4","gravatar_id":"","url":"https://api.github.com/users/monouser7dig","html_url":"https://github.com/monouser7dig","followers_url":"https://api.github.com/users/monouser7dig/followers","following_url":"https://api.github.com/users/monouser7dig/following{/other_user}","gists_url":"https://api.github.com/users/monouser7dig/gists{/gist_id}","starred_url":"https://api.github.com/users/monouser7dig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monouser7dig/subscriptions","organizations_url":"https://api.github.com/users/monouser7dig/orgs","repos_url":"https://api.github.com/users/monouser7dig/repos","events_url":"https://api.github.com/users/monouser7dig/events{/privacy}","received_events_url":"https://api.github.com/users/monouser7dig/received_events","type":"User","site_admin":false},"created_at":"2018-06-12T21:43:49Z","updated_at":"2018-06-12T21:43:49Z","author_association":"NONE","body":"I'm not sure I understand the motivation for tags. Could you give a written, practical example maybe?\r\n\r\nafter all I see this sounds easy for you and you want to continue working on harder topics which is great 😃 \r\n\r\nthanks "}}
{"actor":{"display_login":"monouser7dig"}}