{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/25179","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/25179/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/25179/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/25179/events","html_url":"https://github.com/dart-lang/sdk/issues/25179","id":121094356,"number":25179,"title":"support declaration & use of generic function types","user":{"login":"jmesserly","id":1081711,"avatar_url":"https://avatars.githubusercontent.com/u/1081711?v=3","gravatar_id":"","url":"https://api.github.com/users/jmesserly","html_url":"https://github.com/jmesserly","followers_url":"https://api.github.com/users/jmesserly/followers","following_url":"https://api.github.com/users/jmesserly/following{/other_user}","gists_url":"https://api.github.com/users/jmesserly/gists{/gist_id}","starred_url":"https://api.github.com/users/jmesserly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmesserly/subscriptions","organizations_url":"https://api.github.com/users/jmesserly/orgs","repos_url":"https://api.github.com/users/jmesserly/repos","events_url":"https://api.github.com/users/jmesserly/events{/privacy}","received_events_url":"https://api.github.com/users/jmesserly/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dart-lang/sdk/labels/analyzer-strong-mode","name":"analyzer-strong-mode","color":"d4c5f9"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-analyzer","name":"area-analyzer","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/Priority-Medium","name":"Priority-Medium","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-08T20:38:56Z","updated_at":"2015-12-08T21:23:23Z","closed_at":null,"body":"We have strong mode support for generic methods. Internally we can model types like `<T>(T) -> T` however you can't write this type in code. Typedefs are pretty close but the implicit-dynamic type args prevent it from working. Here are a few syntaxes we've played with:\r\n```dart\r\n// alternative A\r\ntypedef /*generic*/ T F<T>(T t);\r\nF f; // can be called like: f<int>(42)\r\n\r\n// alternative B\r\ntypedef T F<T>(T t);\r\nF/*<>*/ f;\r\n```\r\n\r\n\"A\" has the benefit that you can declare the type once, and then use it freely. Using it doesn't require understanding much about the type.\r\n\r\n\"B\" has the benefit that it works with existing typedefs, doesn't change Dart's implicit-dynamic rules, and could work for classes too. (There's also [precedent in C#](https://msdn.microsoft.com/library/58918ffs(v=vs.100).aspx)).\r\n\r\nCC @leafpetersen \r\n"},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/163021772","html_url":"https://github.com/dart-lang/sdk/issues/25179#issuecomment-163021772","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/25179","id":163021772,"user":{"login":"leafpetersen","id":8484504,"avatar_url":"https://avatars.githubusercontent.com/u/8484504?v=3","gravatar_id":"","url":"https://api.github.com/users/leafpetersen","html_url":"https://github.com/leafpetersen","followers_url":"https://api.github.com/users/leafpetersen/followers","following_url":"https://api.github.com/users/leafpetersen/following{/other_user}","gists_url":"https://api.github.com/users/leafpetersen/gists{/gist_id}","starred_url":"https://api.github.com/users/leafpetersen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leafpetersen/subscriptions","organizations_url":"https://api.github.com/users/leafpetersen/orgs","repos_url":"https://api.github.com/users/leafpetersen/repos","events_url":"https://api.github.com/users/leafpetersen/events{/privacy}","received_events_url":"https://api.github.com/users/leafpetersen/received_events","type":"User","site_admin":false},"created_at":"2015-12-08T21:23:23Z","updated_at":"2015-12-08T21:23:23Z","body":"@bwilkerson As it stands at the moment, you can write a function which takes a generic function as a parameter (using the function typed parameter syntax), but you can't write a typed function which returns a generic function, and you can't bind a generic function to an explicitly typed variable or a field.\r\n\r\nThe two best syntax proposals I've seen so far are basically the uncommented versions of the two approaches that @jmesserly wrote above.  I don't have strong feelings yet as to which works out better."}}