{"action":"created","issue":{"url":"https://api.github.com/repos/ark-lang/ark/issues/398","labels_url":"https://api.github.com/repos/ark-lang/ark/issues/398/labels{/name}","comments_url":"https://api.github.com/repos/ark-lang/ark/issues/398/comments","events_url":"https://api.github.com/repos/ark-lang/ark/issues/398/events","html_url":"https://github.com/ark-lang/ark/issues/398","id":83714612,"number":398,"title":"Generics","user":{"login":"MovingtoMars","id":596124,"avatar_url":"https://avatars.githubusercontent.com/u/596124?v=3","gravatar_id":"","url":"https://api.github.com/users/MovingtoMars","html_url":"https://github.com/MovingtoMars","followers_url":"https://api.github.com/users/MovingtoMars/followers","following_url":"https://api.github.com/users/MovingtoMars/following{/other_user}","gists_url":"https://api.github.com/users/MovingtoMars/gists{/gist_id}","starred_url":"https://api.github.com/users/MovingtoMars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MovingtoMars/subscriptions","organizations_url":"https://api.github.com/users/MovingtoMars/orgs","repos_url":"https://api.github.com/users/MovingtoMars/repos","events_url":"https://api.github.com/users/MovingtoMars/events{/privacy}","received_events_url":"https://api.github.com/users/MovingtoMars/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ark-lang/ark/labels/M-RFC","name":"M-RFC","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-06-01T22:03:55Z","updated_at":"2015-07-15T20:19:05Z","closed_at":null,"body":"# Generics Proposal\r\n\r\n## Motivations\r\nThe main reason for generics is to allow container types to be used by any type, yet type safe. This will be especially helpful for structures such as vectors and trees.\r\n\r\nAlso, in Ark, traits must be used in combination with generics, as traits are static (eg. Rust) and not dynamic (eg. Go and Rust). Unless traits are implemented dynamically, adding runtime overhead, traits must be used with generics.\r\n\r\n## Syntax\r\n@felixangell suggested attribute-like syntax: `[T: SomeTrait]`.\r\nI prefer the more common syntax `<T: SomeTrait>`.\r\n\r\nThe containing brackets aside, here is the syntax for generics declarations:\r\n* `<TypeIdentifier>`\r\n* `<TypeIdentifier: TraitConstraint>`\r\n* probably a few more that could be added\r\n\r\n## Implementation\r\nStatic generics will require code generation for all the different types that call the generic function. This will require name mangling, so it's a good idea for us to draft an Ark name mangling specification.\r\n\r\nGenerics will probably be implemented in the parser rather than the codegen.\r\n\r\n## What next\r\nThe current proposal lacks the important details about the semantics of generics, which need to be sorted out.\r\n\r\nMore detail and suggestions are welcome."},"comment":{"url":"https://api.github.com/repos/ark-lang/ark/issues/comments/121734179","html_url":"https://github.com/ark-lang/ark/issues/398#issuecomment-121734179","issue_url":"https://api.github.com/repos/ark-lang/ark/issues/398","id":121734179,"user":{"login":"MovingtoMars","id":596124,"avatar_url":"https://avatars.githubusercontent.com/u/596124?v=3","gravatar_id":"","url":"https://api.github.com/users/MovingtoMars","html_url":"https://github.com/MovingtoMars","followers_url":"https://api.github.com/users/MovingtoMars/followers","following_url":"https://api.github.com/users/MovingtoMars/following{/other_user}","gists_url":"https://api.github.com/users/MovingtoMars/gists{/gist_id}","starred_url":"https://api.github.com/users/MovingtoMars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MovingtoMars/subscriptions","organizations_url":"https://api.github.com/users/MovingtoMars/orgs","repos_url":"https://api.github.com/users/MovingtoMars/repos","events_url":"https://api.github.com/users/MovingtoMars/events{/privacy}","received_events_url":"https://api.github.com/users/MovingtoMars/received_events","type":"User","site_admin":false},"created_at":"2015-07-15T20:19:05Z","updated_at":"2015-07-15T20:19:05Z","body":"I'm still against `[]` syntax. It doesn't make sense. We should just use `<>`."}}