OLD | NEW |
---|---|
(Empty) | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 <!DOCTYPE html> | |
8 <html lang="en"> | |
9 <head> | |
10 <meta charset="utf-8"> | |
11 | |
Lasse Reichstein Nielsen
2017/04/24 13:02:05
The document has extension .md, but contains HTML.
eernst
2017/04/25 11:57:15
Fixed.
| |
12 | |
13 | |
14 <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/frame works-d7b19415c108234b91acac0d0c02091c860993c13687a757ee345cc1ecd3a9d1.css" medi a="all" rel="stylesheet" /> | |
15 <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/githu b-678c6c9fa597e3eabad2135736d58fe40e2ef37d8e272589d7d39d7c1c0f9056.css" media="a ll" rel="stylesheet" /> | |
16 | |
17 | |
18 <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/site- 537c466d44a69d38c4bd60c2fd2955373ef96d051bd97b2ad30ed039acc97bff.css" media="all " rel="stylesheet" /> | |
19 | |
20 | |
21 <meta name="viewport" content="width=device-width"> | |
22 | |
23 <title>INFORMAL SPECIFICATION: Generic Function Type Alias · GitHub</title> | |
24 <link rel="search" type="application/opensearchdescription+xml" href="/opensea rch.xml" title="GitHub"> | |
25 <link rel="fluid-icon" href="https://gist.github.com/fluidicon.png" title="Git Hub"> | |
26 <meta property="fb:app_id" content="1401488693436528"> | |
27 | |
28 | |
29 <meta content="https://avatars3.githubusercontent.com/u/9606994?v=3&s=40 0" property="og:image" /><meta content="Gist" property="og:site_name" /><meta co ntent="object" property="og:type" /><meta content="INFORMAL SPECIFICATION: Gener ic Function Type Alias" property="og:title" /><meta content="https://gist.github .com/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa" property="og:url" /><meta content ="INFORMAL SPECIFICATION: Generic Function Type Alias" property="og:description" /> | |
30 | |
31 <link rel="assets" href="https://assets-cdn.github.com/"> | |
32 | |
33 <meta name="pjax-timeout" content="1000"> | |
34 | |
35 <meta name="request-id" content="CE98:2758B:2C00754:46C66AC:58FDDC27" data-pja x-transient> | |
36 | |
37 | |
38 <meta name="selected-link" value="gist_code" data-pjax-transient> | |
39 | |
40 <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r 1XQysX3xurLU"> | |
41 <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVi hD0exw2fsA"> | |
42 <meta name="google-analytics" content="UA-3769691-4"> | |
43 | |
44 <meta content="collector.githubapp.com" name="octolytics-host" /><meta content=" gist" name="octolytics-app-id" /><meta content="https://collector.githubapp.com/ github-external/browser_event" name="octolytics-event-url" /><meta content="CE98 :2758B:2C00754:46C66AC:58FDDC27" name="octolytics-dimension-request_id" /> | |
45 <meta content="/<user-name>/<gist-id>" data-pjax-transient="true" na me="analytics-location" /> | |
46 | |
47 | |
48 | |
49 | |
50 <meta class="js-ga-set" name="dimension1" content="Logged Out"> | |
51 | |
52 | |
53 | |
54 <meta content="true" name="octolytics-dimension-public" /><meta content="429 10666" name="octolytics-dimension-gist_id" /><meta content="ffc7bd281974e9018f10 f0cb6cfee4aa" name="octolytics-dimension-gist_name" /><meta content="false" name ="octolytics-dimension-anonymous" /><meta content="9606994" name="octolytics-dim ension-owner_id" /><meta content="eernstg" name="octolytics-dimension-owner_logi n" /><meta content="false" name="octolytics-dimension-forked" /> | |
55 | |
56 <meta class="js-ga-set" name="dimension5" content="public"> | |
57 <meta class="js-ga-set" name="dimension6" content="owned"> | |
58 <meta class="js-ga-set" name="dimension7" content="markdown"> | |
59 | |
60 | |
61 <meta name="hostname" content="gist.github.com"> | |
62 <meta name="user-login" content=""> | |
63 | |
64 <meta name="expected-hostname" content="gist.github.com"> | |
65 <meta name="js-proxy-site-detection-payload" content="Zjg3ZjIwNTUyZjZhOWY0Nj cxZWQzZDkyOWRmNGE5ZmMxYWE4ZDhhZTQ4NTc3MmFhZjYzNjM2ZmY2MGUwM2Y2MXx7InJlbW90ZV9hZG RyZXNzIjoiMTA0LjEzMi4xODAuMTk4IiwicmVxdWVzdF9pZCI6IkNFOTg6Mjc1OEI6MkMwMDc1NDo0Nk M2NkFDOjU4RkREQzI3IiwidGltZXN0YW1wIjoxNDkzMDMxOTc1LCJob3N0IjoiZ2l0aHViLmNvbSJ9"> | |
66 | |
67 | |
68 <meta name="html-safe-nonce" content="641be3c5eee41a088cf23e80ff9618ddc83c8f54 "> | |
69 | |
70 <meta http-equiv="x-pjax-version" content="2e017d75c6ea5cb7f0c7e24d0a0382b8"> | |
71 | |
72 | |
73 <link href="/eernstg.atom" rel="alternate" title="atom" type="application/ atom+xml"> | |
74 | |
75 <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/gist- 67dd5139d22e4e9921ef362b5458f51e5973a20db04a54c9d74116748f852917.css" media="all " rel="stylesheet" /> | |
76 | |
77 | |
78 | |
79 | |
80 <meta name="browser-stats-url" content="https://api.github.com/_private/browse r/stats"> | |
81 | |
82 <meta name="browser-errors-url" content="https://api.github.com/_private/brows er/errors"> | |
83 | |
84 <link rel="mask-icon" href="https://assets-cdn.github.com/pinned-octocat.svg" color="#000000"> | |
85 <link rel="icon" type="image/x-icon" href="https://assets-cdn.github.com/favic on.ico"> | |
86 | |
87 <meta name="theme-color" content="#1e2327"> | |
88 | |
89 | |
90 | |
91 </head> | |
92 | |
93 <body class="logged-out env-production"> | |
94 | |
95 | |
96 | |
97 <div class="position-relative js-header-wrapper "> | |
98 <a href="#start-of-content" tabindex="1" class="accessibility-aid js-skip-to -content">Skip to content</a> | |
99 <div id="js-pjax-loader-bar" class="pjax-loader-bar"><div class="progress">< /div></div> | |
100 | |
101 | |
102 | |
103 | |
104 | |
105 | |
106 | |
107 <div class="header gist-header header-logged-out" role="banner"> | |
108 <div class="container clearfix"> | |
109 | |
110 <a href="/" aria-label="Gist Homepage" class="header-logo-wordmark" data-hot key="g d"> | |
111 <svg aria-hidden="true" class="octicon octicon-logo-github" height="28" ve rsion="1.1" viewBox="0 0 45 16" width="78"><path fill-rule="evenodd" d="M18.53 1 2.03h-.02c.009 0 .015.01.024.011h.006l-.01-.01zm.004.011c-.093.001-.327.05-.574. 05-.78 0-1.05-.36-1.05-.83V8.13h1.59c.09 0 .16-.08.16-.19v-1.7c0-.09-.08-.17-.16 -.17h-1.59V3.96c0-.08-.05-.13-.14-.13h-2.16c-.09 0-.14.05-.14.13v2.17s-1.09.27-1 .16.28c-.08.02-.13.09-.13.17v1.36c0 .11.08.19.17.19h1.11v3.28c0 2.44 1.7 2.69 2. 86 2.69.53 0 1.17-.17 1.27-.22.06-.02.09-.09.09-.16v-1.5a.177.177 0 0 0-.146-.18 zm23.696-2.2c0-1.81-.73-2.05-1.5-1.97-.6.04-1.08.34-1.08.34v3.52s.49.34 1.22.36c 1.03.03 1.36-.34 1.36-2.25zm2.43-.16c0 3.43-1.11 4.41-3.05 4.41-1.64 0-2.52-.83- 2.52-.83s-.04.46-.09.52c-.03.06-.08.08-.14.08h-1.48c-.1 0-.19-.08-.19-.17l.02-11 .11c0-.09.08-.17.17-.17h2.13c.09 0 .17.08.17.17v3.77s.82-.53 2.02-.53l-.01-.02c1 .2 0 2.97.45 2.97 3.88zm-8.72-3.61H33.84c-.11 0-.17.08-.17.19v5.44s-.55.39-1.3.3 9-.97-.34-.97-1.09V6.25c0-.09-.08-.17-.17-.17h-2.14c-.09 0-.17.08-.17.17v5.11c0 2.2 1.23 2.75 2.92 2.75 1.39 0 2.52-.77 2.52-.77s.05.39.08.45c.02.05.09.09.16.09 h1.34c.11 0 .17-.08.17-.17l.02-7.47c0-.09-.08-.17-.19-.17zm-23.7-.01h-2.13c-.09 0-.17.09-.17.2v7.34c0 .2.13.27.3.27h1.92c.2 0 .25-.09.25-.27V6.23c0-.09-.08-.17- .17-.17zm-1.05-3.38c-.77 0-1.38.61-1.38 1.38 0 .77.61 1.38 1.38 1.38.75 0 1.36-. 61 1.36-1.38 0-.77-.61-1.38-1.36-1.38zm16.49-.25h-2.11c-.09 0-.17.08-.17.17v4.09 h-3.31V2.6c0-.09-.08-.17-.17-.17h-2.13c-.09 0-.17.08-.17.17v11.11c0 .09.09.17.17 .17h2.13c.09 0 .17-.08.17-.17V8.96h3.31l-.02 4.75c0 .09.08.17.17.17h2.13c.09 0 . 17-.08.17-.17V2.6c0-.09-.08-.17-.17-.17zM8.81 7.35v5.74c0 .04-.01.11-.06.13 0 0- 1.25.89-3.31.89-2.49 0-5.44-.78-5.44-5.92S2.58 1.99 5.1 2c2.18 0 3.06.49 3.2.58. 04.05.06.09.06.14L7.94 4.5c0 .09-.09.2-.2.17-.36-.11-.9-.33-2.17-.33-1.47 0-3.05 .42-3.05 3.73s1.5 3.7 2.58 3.7c.92 0 1.25-.11 1.25-.11v-2.3H4.88c-.11 0-.19-.08- .19-.17V7.35c0-.09.08-.17.19-.17h3.74c.11 0 .19.08.19.17z"/></svg> | |
112 <svg aria-hidden="true" class="octicon octicon-logo-gist" height="28" vers ion="1.1" viewBox="0 0 25 16" width="40"><path fill-rule="evenodd" d="M4.7 8.73h 2.45v4.02c-.55.27-1.64.34-2.53.34-2.56 0-3.47-2.2-3.47-5.05 0-2.85.91-5.06 3.48- 5.06 1.28 0 2.06.23 3.28.73V2.66C7.27 2.33 6.25 2 4.63 2 1.13 2 0 4.69 0 8.03c0 3.34 1.11 6.03 4.63 6.03 1.64 0 2.81-.27 3.59-.64V7.73H4.7v1zm6.39 3.72V6.06h-1. 05v6.28c0 1.25.58 1.72 1.72 1.72v-.89c-.48 0-.67-.16-.67-.7v-.02zm.25-8.72c0-.44 -.33-.78-.78-.78s-.77.34-.77.78.33.78.77.78.78-.34.78-.78zm4.34 5.69c-1.5-.13-1. 78-.48-1.78-1.17 0-.77.33-1.34 1.88-1.34 1.05 0 1.66.16 2.27.36v-.94c-.69-.3-1.5 2-.39-2.25-.39-2.2 0-2.92 1.2-2.92 2.31 0 1.08.47 1.88 2.73 2.08 1.55.13 1.77.63 1.77 1.34 0 .73-.44 1.42-2.06 1.42-1.11 0-1.86-.19-2.33-.36v.94c.5.2 1.58.39 2. 33.39 2.38 0 3.14-1.2 3.14-2.41 0-1.28-.53-2.03-2.75-2.23h-.03zm8.58-2.47v-.86h- 2.42v-2.5l-1.08.31v2.11l-1.56.44v.48h1.56v5c0 1.53 1.19 2.13 2.5 2.13.19 0 .52-. 02.69-.05v-.89c-.19.03-.41.03-.61.03-.97 0-1.5-.39-1.5-1.34V6.94h2.42v.02-.01z"/ ></svg> | |
113 </a> | |
114 <div class="site-search js-site-search" role="search"> | |
115 <div class="header-search" role="search"> | |
116 | |
117 <!-- '"` --><!-- </textarea></xmp> --></option></form><form accept-charset="UTF- 8" action="/search" class="position-relative" method="get"><div style="margin:0; padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></ div> | |
118 <label class="header-search-wrapper form-control js-chromeless-input-container "> | |
119 <input type="text" | |
120 class="form-control js-site-search-focus header-search-input" | |
121 data-hotkey="s" | |
122 name="q" | |
123 placeholder="Search…" | |
124 tabindex="1" | |
125 autocorrect="off" | |
126 autocomplete="off" | |
127 autocapitalize="off"> | |
128 </label> | |
129 | |
130 </form></div> | |
131 | |
132 </div> | |
133 <ul class="header-nav float-left" role="navigation"> | |
134 <li class="header-nav-item"> | |
135 <a href="/discover" class="header-nav-link" data-ga-click="Header, go to all gists, text:all gists">All gists</a> | |
136 </li> | |
137 | |
138 <li class="header-nav-item"> | |
139 <a href="https://github.com" class="header-nav-link" data-ga-click="Head er, go to GitHub, text:GitHub">GitHub</a> | |
140 </li> | |
141 </ul> | |
142 | |
143 <div class="header-actions" role="navigation"> | |
144 <a href="/join?source=header-gist" class="btn btn-primary" data-ga-cli ck="Header, sign up">Sign up for a GitHub account</a> | |
145 <a href="https://gist.github.com/auth/github?return_to=gist" class="btn" data-ga-click="Header, sign in">Sign in</a> | |
146 </div> | |
147 </div> | |
148 </div> | |
149 | |
150 | |
151 | |
152 </div> | |
153 | |
154 <div id="start-of-content" class="accessibility-aid"></div> | |
155 | |
156 <div id="js-flash-container"> | |
157 </div> | |
158 | |
159 | |
160 | |
161 <div role="main"> | |
162 <div itemscope itemtype="http://schema.org/Code"> | |
163 <div id="gist-pjax-container" class="gist-content-wrapper" data-pjax-contain er> | |
164 | |
165 | |
166 | |
167 <div class="gist-detail-intro gist-banner"> | |
168 <div class="container"> | |
169 <a href="/" class="btn btn-outline float-right">Create a gist now</a> | |
170 <p class="lead"> | |
171 Instantly share code, notes, and snippets. | |
172 </p> | |
173 </div> | |
174 </div> | |
175 | |
176 | |
177 <div class="gisthead pagehead repohead instapaper_ignore readability-menu experi ment-repo-nav mb-4"> | |
178 <div class="container"> | |
179 | |
180 | |
181 <div class="container repohead-details-container"> | |
182 | |
183 <ul class="pagehead-actions"> | |
184 | |
185 | |
186 <li> | |
187 <a href="/login?return_to=https%3A%2F%2Fgist.github.com%2Feernstg%2Fffc7 bd281974e9018f10f0cb6cfee4aa" aria-label="You must be signed in to star a gist" class="btn btn-sm btn-with-count tooltipped tooltipped-n" rel="nofollow"> | |
188 <svg aria-hidden="true" class="octicon octicon-star" height="16" version="1. 1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74z"/></svg> | |
189 Star | |
190 </a> | |
191 <a href="/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa/stargazers" aria-label="0 u sers starred this gist" class="social-count"> | |
192 0 | |
193 </a> | |
194 </li> | |
195 | |
196 <li> | |
197 <a href="/login?return_to=https%3A%2F%2Fgist.github.com%2Feernstg%2Fff c7bd281974e9018f10f0cb6cfee4aa" aria-label="You must be signed in to fork a gist " class="btn btn-sm btn-with-count tooltipped tooltipped-n" rel="nofollow"> | |
198 <svg aria-hidden="true" class="octicon octicon-repo-forked" height="16" vers ion="1.1" viewBox="0 0 10 16" width="10"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.7 2V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.99 3 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1. 2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1. 2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/></svg> | |
199 Fork | |
200 </a> | |
201 <a href="/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa/forks" aria-label="0 users forked this gist" class="social-count"> | |
202 0 | |
203 </a> | |
204 </li> | |
205 | |
206 </ul> | |
207 | |
208 <h1 class="public css-truncate"> | |
209 <img alt="@eernstg" class="avatar gist-avatar" height="26" src="https://avat ars1.githubusercontent.com/u/9606994?v=3&s=52" width="26" /> | |
210 <span class="author"><a href="/eernstg" class="url fn" rel="author"><span it emprop="author">eernstg</span></a></span><!-- | |
211 --><span class="path-divider">/</span><!-- | |
212 --><strong itemprop="name" class="gist-header-title css-truncate-target" ><a href="/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa">GenericFunctionTypeAlias.md </a></strong> | |
213 | |
214 <div class="gist-timestamp">Last active <time-ago datetime="2017-01-04T11:41 :57Z">Jan 4, 2017</time-ago></div> | |
215 </h1> | |
216 </div> | |
217 | |
218 <div class="container gist-file-navigation"> | |
219 <div class="float-right file-navigation-options" data-multiple> | |
220 | |
221 <div class="file-navigation-option"> | |
222 <input type="hidden" name="protocol_type" value="clone"> | |
223 | |
224 <div class="select-menu js-menu-container js-select-menu"> | |
225 <div class="input-group js-select-button js-zeroclipboard-container"> | |
226 <div class="input-group-button"> | |
227 <button type="button" class="btn btn-sm select-menu-button js-menu-target" dat a-ga-click="Repository, clone Embed, location:repo overview"> | |
228 Embed | |
229 </button> | |
230 </div> | |
231 <input type="text" class="form-control input-monospace input-sm js-zeroclipboard -target js-url-field" value="<script src="https://gist.github.com/eernst g/ffc7bd281974e9018f10f0cb6cfee4aa.js"></script>" aria-label="Clon e this repository at <script src="https://gist.github.com/eernstg/ffc7bd 281974e9018f10f0cb6cfee4aa.js"></script>" readonly> | |
232 <div class="input-group-button"> | |
233 <button aria-label="Copy to clipboard" class="js-zeroclipboard btn btn-sm zero clipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="butto n"><svg aria-hidden="true" class="octicon octicon-clippy" height="16" version="1 .1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm 5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2 c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0- 1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-. 45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"/ ></svg></button> | |
234 </div> | |
235 | |
236 </div> | |
237 | |
238 <div class="select-menu-modal-holder"> | |
239 <div class="select-menu-modal js-menu-content"> | |
240 <div class="select-menu-header"> | |
241 <svg aria-label="Close" class="octicon octicon-x js-menu-close" height ="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="e venodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4. 25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg> | |
242 <span class="select-menu-title">What would you like to do?</span> | |
243 </div> | |
244 | |
245 <div class="select-menu-list js-navigation-container" role="menu"> | |
246 <div class="select-menu-item js-navigation-item selected" role="menu item" tabindex="0"> | |
247 <svg aria-hidden="true" class="octicon octicon-check select-menu-i tem-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-ru le="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"/></svg> | |
248 <div class="select-menu-item-text"> | |
249 <input type="radio" name="protocol_selector" value="embed" check ed> | |
250 <span class="select-menu-item-heading"> | |
251 | |
252 Embed | |
253 </span> | |
254 <span class="description"> | |
255 Embed this gist in your website. | |
256 </span> | |
257 <span class="js-select-button-text hidden-select-button-text"> | |
258 <div class="input-group-button"> | |
259 <button type="button" class="btn btn-sm select-menu-button js-menu-target" dat a-ga-click="Repository, clone Embed, location:repo overview"> | |
260 Embed | |
261 </button> | |
262 </div> | |
263 <input type="text" class="form-control input-monospace input-sm js-zeroclipboard -target js-url-field" value="<script src="https://gist.github.com/eernst g/ffc7bd281974e9018f10f0cb6cfee4aa.js"></script>" aria-label="Clon e this repository at <script src="https://gist.github.com/eernstg/ffc7bd 281974e9018f10f0cb6cfee4aa.js"></script>" readonly> | |
264 <div class="input-group-button"> | |
265 <button aria-label="Copy to clipboard" class="js-zeroclipboard btn btn-sm zero clipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="butto n"><svg aria-hidden="true" class="octicon octicon-clippy" height="16" version="1 .1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm 5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2 c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0- 1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-. 45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"/ ></svg></button> | |
266 </div> | |
267 | |
268 </span> | |
269 </div> | |
270 </div> | |
271 <div class="select-menu-item js-navigation-item " role="menuitem" ta bindex="0"> | |
272 <svg aria-hidden="true" class="octicon octicon-check select-menu-i tem-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-ru le="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"/></svg> | |
273 <div class="select-menu-item-text"> | |
274 <input type="radio" name="protocol_selector" value="share" > | |
275 <span class="select-menu-item-heading"> | |
276 | |
277 Share | |
278 </span> | |
279 <span class="description"> | |
280 Copy sharable URL for this gist. | |
281 </span> | |
282 <span class="js-select-button-text hidden-select-button-text"> | |
283 <div class="input-group-button"> | |
284 <button type="button" class="btn btn-sm select-menu-button js-menu-target" dat a-ga-click="Repository, clone Share, location:repo overview"> | |
285 Share | |
286 </button> | |
287 </div> | |
288 <input type="text" class="form-control input-monospace input-sm js-zeroclipboard -target js-url-field" value="https://gist.github.com/eernstg/ffc7bd281974e9018f1 0f0cb6cfee4aa" aria-label="Clone this repository at https://gist.github.com/eern stg/ffc7bd281974e9018f10f0cb6cfee4aa" readonly> | |
289 <div class="input-group-button"> | |
290 <button aria-label="Copy to clipboard" class="js-zeroclipboard btn btn-sm zero clipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="butto n"><svg aria-hidden="true" class="octicon octicon-clippy" height="16" version="1 .1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm 5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2 c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0- 1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-. 45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"/ ></svg></button> | |
291 </div> | |
292 | |
293 </span> | |
294 </div> | |
295 </div> | |
296 <div class="select-menu-item js-navigation-item " role="menuitem" ta bindex="0"> | |
297 <svg aria-hidden="true" class="octicon octicon-check select-menu-i tem-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-ru le="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"/></svg> | |
298 <div class="select-menu-item-text"> | |
299 <input type="radio" name="protocol_selector" value="http" > | |
300 <span class="select-menu-item-heading"> | |
301 Clone via | |
302 HTTPS | |
303 </span> | |
304 <span class="description"> | |
305 Clone with Git or checkout with SVN using the repository's w eb address. | |
306 </span> | |
307 <span class="js-select-button-text hidden-select-button-text"> | |
308 <div class="input-group-button"> | |
309 <button type="button" class="btn btn-sm select-menu-button js-menu-target" dat a-ga-click="Repository, clone HTTPS, location:repo overview"> | |
310 HTTPS | |
311 </button> | |
312 </div> | |
313 <input type="text" class="form-control input-monospace input-sm js-zeroclipboard -target js-url-field" value="https://gist.github.com/ffc7bd281974e9018f10f0cb6cf ee4aa.git" aria-label="Clone this repository at https://gist.github.com/ffc7bd28 1974e9018f10f0cb6cfee4aa.git" readonly> | |
314 <div class="input-group-button"> | |
315 <button aria-label="Copy to clipboard" class="js-zeroclipboard btn btn-sm zero clipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="butto n"><svg aria-hidden="true" class="octicon octicon-clippy" height="16" version="1 .1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm 5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2 c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0- 1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-. 45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"/ ></svg></button> | |
316 </div> | |
317 | |
318 </span> | |
319 </div> | |
320 </div> | |
321 </div> | |
322 <div class="select-menu-list" role="menu"> | |
323 <a class="select-menu-item select-menu-action" href="https://help.gith ub.com/articles/which-remote-url-should-i-use" target="_blank"> | |
324 <svg aria-hidden="true" class="octicon octicon-question select-menu- item-icon" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-r ule="evenodd" d="M6 10h2v2H6v-2zm4-3.5C10 8.64 8 9 8 9H6c0-.55.45-1 1-1h.5c.28 0 .5-.22.5-.5v-1c0-.28-.22-.5-.5-.5h-1c-.28 0-.5.22-.5.5V7H4c0-1.5 1.5-3 3-3s3 1 3 2.5zM7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3 .14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7z"/> </svg> | |
325 <div class="select-menu-item-text"> | |
326 Learn more about clone URLs | |
327 </div> | |
328 </a> | |
329 </div> | |
330 </div> | |
331 </div> | |
332 </div> | |
333 </div> | |
334 | |
335 | |
336 <div class="file-navigation-option"> | |
337 </div> | |
338 | |
339 | |
340 <div class="file-navigation-option"> | |
341 <a href="/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa/archive/99158a070435c0e f7a13abd49b04de53248ef82b.zip" | |
342 class="btn btn-sm" | |
343 rel="nofollow" | |
344 data-ga-click="Gist, download zip, location:gist overview"> | |
345 Download ZIP | |
346 </a> | |
347 </div> | |
348 </div> | |
349 | |
350 <div class="float-left"> | |
351 <nav class="reponav js-repo-nav js-sidenav-container-pjax" | |
352 role="navigation" | |
353 data-pjax="#gist-pjax-container"> | |
354 | |
355 <a href="/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa" aria-label="Code" class="j s-selected-navigation-item selected reponav-item" data-hotkey="g c" data-pjax="t rue" data-selected-links="gist_code /eernstg/ffc7bd281974e9018f10f0cb6cfee4aa"> | |
356 <svg aria-hidden="true" class="octicon octicon-code" height="16" version="1. 1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"/></svg> | |
357 Code | |
358 </a> | |
359 <a href="/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa/revisions" aria-label="Re visions" class="js-selected-navigation-item reponav-item" data-hotkey="g r" data -pjax="true" data-selected-links="gist_revisions /eernstg/ffc7bd281974e9018f10f0 cb6cfee4aa/revisions"> | |
360 <svg aria-hidden="true" class="octicon octicon-git-commit" height="16" ver sion="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M10.86 7c -.45-1.72-2-3-3.86-3-1.86 0-3.41 1.28-3.86 3H0v2h3.14c.45 1.72 2 3 3.86 3 1.86 0 3.41-1.28 3.86-3H14V7h-3.14zM7 10.2c-1.22 0-2.2-.98-2.2-2.2 0-1.22.98-2.2 2.2-2 .2 1.22 0 2.2.98 2.2 2.2 0 1.22-.98 2.2-2.2 2.2z"/></svg> | |
361 Revisions | |
362 <span class="Counter">35</span> | |
363 </a> | |
364 | |
365 </nav> | |
366 | |
367 </div> | |
368 </div> | |
369 | |
370 | |
371 </div> | |
372 </div> | |
373 | |
374 <div class="container new-discussion-timeline experiment-repo-nav"> | |
375 <div class="repository-content gist-content"> | |
376 | |
377 <div> | |
378 <div class="repository-meta js-details-container Details"> | |
379 <div class="repository-meta-content" itemprop="about"> | |
380 INFORMAL SPECIFICATION: Generic Function Type Alias | |
381 </div> | |
382 </div> | |
383 | |
384 | |
385 <div class="js-gist-file-update-container js-task-list-container file-bo x"> | |
386 <div id="file-genericfunctiontypealias-md" class="file"> | |
387 <div class="file-header"> | |
388 <div class="file-actions"> | |
389 | |
390 <a href="/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa/raw/99158a070435c0e f7a13abd49b04de53248ef82b/GenericFunctionTypeAlias.md" class="btn btn-sm ">Raw</ a> | |
391 </div> | |
392 <div class="file-info"> | |
393 <span class="icon"> | |
394 <svg aria-hidden="true" class="octicon octicon-gist" height="16" ver sion="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.5 5L10 7.5 7.5 10l-.75-.75L8.5 7.5 6.75 5.75 7.5 5zm-3 0L2 7.5 4.5 10l.75-.75L3.5 7.5l 1.75-1.75L4.5 5zM0 13V2c0-.55.45-1 1-1h10c.55 0 1 .45 1 1v11c0 .55-.45 1-1 1H1c- .55 0-1-.45-1-1zm1 0h10V2H1v11z"/></svg> | |
395 </span> | |
396 <a class="tooltipped tooltipped-s css-truncate" aria-label="Permalink" href="#file-genericfunctiontypealias-md"> | |
397 <strong class="user-select-contain gist-blob-name css-truncate-targe t"> | |
398 GenericFunctionTypeAlias.md | |
399 </strong> | |
400 </a> | |
401 </div> | |
402 </div> | |
403 | |
404 <div id="readme" class="readme blob instapaper_body"> | |
405 <article class="markdown-body entry-content" itemprop="text"><h1><a id="user -content-feature-generic-function-type-alias" class="anchor" href="#feature-gene ric-function-type-alias" aria-hidden="true"><svg aria-hidden="true" class="octic on octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-. 98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2 -1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 1 3h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Feature: Generic Function Type Alias</h1> | |
406 <p><strong>Status</strong>: Under implementation.</p> | |
407 <p><strong>This document</strong> is an informal specification of a feature supp orting the | |
408 definition of function type aliases using a more expressive syntax than the | |
409 one available today, such that it also covers generic function types. The | |
410 feature also introduces syntax for specifying function types directly, such | |
411 that they can be used in type annotations etc. without going via a | |
412 <code>typedef</code>. This feature is being introduced into Dart starting Q4, 2 016.</p> | |
413 <p><strong>This feature</strong> introduces a new syntactic form of typedef decl aration | |
414 which includes an identifier and a type, connecting the two with an equals | |
415 sign, <code>=</code>. The effect of such a declaration is that the name is decla red to | |
416 be an alias for the type. Type parameterization may occur in the | |
417 declaration itself, as well as in the declared type. This feature also | |
418 introduces syntax for specifying function types directly, using a syntax | |
419 which is similar to the header of a function declaration.</p> | |
420 <p>The <strong>motivation</strong> for adding this feature is that it allows dev elopers to | |
421 specify generic function types everywhere a type is expected, including | |
422 type annotations, return types, actual type arguments, and formal type | |
423 parameter bounds. Currently there is no way to specify a generic function | |
424 type in these situations. Even in the case where a generic function type | |
425 <em>can</em> be specified (such as a type annotation for a formal parameter) it | |
426 may be useful for readability to declare a name as an alias of a complex | |
427 type, and use that name instead of the type.</p> | |
428 <h2><a id="user-content-examples" class="anchor" href="#examples" aria-hidden="t rue"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1 .1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58- .45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c- 1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z">< /path></svg></a>Examples</h2> | |
429 <p>Using the new syntax, a function type alias may be declared as follows:</p> | |
430 <div class="highlight highlight-source-dart"><pre><span class="pl-k">typedef</sp an> F = List<T> Function<T>(T);</pre></div> | |
431 <p>This declares <code>F</code> to be the type of a function that accepts one ty pe | |
432 parameter <code>T</code> and one value parameter of type <code>T</code> whose na me is | |
433 unspecified, and returns a result of type <code>List<T></code>. It is poss ible to use | |
434 the new syntax to declare function types that we can already declare using | |
435 the existing typedef declaration. For instance, <code>G</code> and <code>H</code > both declare | |
436 the same type:</p> | |
437 <div class="highlight highlight-source-dart"><pre><span class="pl-k">typedef</sp an> G = List<int> Function(<span class="pl-k">int</span>); <span class="pl -c">// New form.</span> | |
438 <span class="pl-k">typedef</span> List<int> H(<span class="pl-k">int</span > i); <span class="pl-c">// Old form.</span></pre></div> | |
439 <p>Note that the name of the parameter is required in the old form, but the | |
440 type may be omitted. In contrast, the type is required in the new form, but | |
441 the name may be omitted.</p> | |
442 <p>The reason for having two ways to express the same thing is that the new | |
443 form seamlessly covers non-generic functions as well as generic ones, and | |
444 developers might prefer to use the new form everywhere, for improved | |
445 readability.</p> | |
446 <p><em>We may deprecate the old form after a while, or we may choose | |
447 to keep it, because it is more concise. We may even change the old form to | |
448 allow omitting the name and not the type when only one identifier is | |
449 specified, if this is not too much of a breaking change. As an intermediate | |
450 step we could change the old form to always require both the type and the | |
451 name, such that no type expressions will silently change meaning.</em></p> | |
452 <p>There is a difference between declaring a generic function type and | |
453 declaring a typedef which takes a type argument. The former is a | |
454 declaration of a single type which describes a certain class of runtime | |
455 entities: Functions that are capable of accepting some type arguments as | |
456 well as some value arguments, both at runtime. The latter is a type-level | |
457 function: It accepts a type argument at compile time and returns a type, | |
458 which may be used, say, as a type annotation. Dart has had support for | |
459 parameterized typedefs for a while, and the new syntax supports | |
460 parameterized typedefs as well. Here is an example of a parameterized | |
461 typedef, and a usage thereof:</p> | |
462 <div class="highlight highlight-source-dart"><pre><span class="pl-k">typedef</sp an> I<T> = List<T> Function(T); <span class="pl-c">// New form.</spa n> | |
463 <span class="pl-k">typedef</span> List<T> J<T>(T t); <span class="pl -c">// Old form.</span> | |
464 I<span class="pl-k"><</span><span class="pl-k">int</span><span class="pl-k">& gt;</span> myFunction(J<span class="pl-k"><</span><span class="pl-k">int</spa n><span class="pl-k">></span> f) <span class="pl-k">=</span><span class="pl-k ">></span> f;</pre></div> | |
465 <p>Here, we have declared two equivalent parameterized typedefs <code>I</code> a nd <code>J</code>, | |
466 and we have used an instantiation of each of them in the type annotations | |
467 on <code>myFunction</code>. Note that the type of <code>myFunction</code> does n ot include <em>any</em> | |
468 generic types, it is just a function that accepts an argument and returns a | |
469 result, both of which have a non-generic function type that we have | |
470 obtained by instantiating a parameterized typedef. The argument type might | |
471 as well have been declared using the traditional function signature syntax, | |
472 and the return type (and the argument type, by the way) might as well have | |
473 been declared using a regular, non-parameterized typedef:</p> | |
474 <div class="highlight highlight-source-dart"><pre><span class="pl-k">typedef</sp an> List<int> K(<span class="pl-k">int</span> i); <span class="pl-c">// Ol d form, non-generic.</span> | |
475 K myFunction2(<span class="pl-k">List</span><span class="pl-k"><</span><span class="pl-k">int</span><span class="pl-k">></span> f(<span class="pl-k">int</ span> i)) <span class="pl-k">=</span><span class="pl-k">></span> f; <span cla ss="pl-c">// Same as myFunction.</span></pre></div> | |
476 <p>The new syntax allows for using the two kinds of type parameters together:</p > | |
477 <div class="highlight highlight-source-dart"><pre><span class="pl-k">typedef</sp an> L<T> = List<T> Function<S>(S, {T Function(<span class="pl- k">int</span>, S) factory});</pre></div> | |
478 <p>This declares <code>L</code> to be a parameterized typedef; when instantiatin g <code>L</code> | |
479 with an actual type argument as in <code>L<String></code>, it becomes the type of a | |
480 generic function that accepts a type argument <code>S</code> and two value argum ents: | |
481 one required positional argument of type <code>S</code>, and one named optional | |
482 argument with name <code>factory</code> and type <code>String Function(int, S)</ code>; finally, | |
483 it returns a value of type <code>List<String></code>.</p> | |
484 <h2><a id="user-content-syntax" class="anchor" href="#syntax" aria-hidden="true" ><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3- 1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09 .53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></pat h></svg></a>Syntax</h2> | |
485 <p>The new form of <code>typedef</code> declaration uses the following syntax (t here are | |
486 no deletions from the grammar; addition of a new rule or a new alternative | |
487 in a rule is marked with NEW and modified rules are marked CHANGED):</p> | |
488 <pre><code>typeAlias: | |
489 metadata 'typedef' typeAliasBody | | |
490 metadata 'typedef' identifier typeParameters? '=' functionType ';' // NE W | |
491 functionType: // NEW | |
492 returnType? 'Function' typeParameters? parameterTypeList | |
493 parameterTypeList: // NEW | |
494 '(' ')' | | |
495 '(' normalParameterTypes ','? ')' | | |
496 '(' normalParameterTypes ',' optionalParameterTypes ')' | | |
497 '(' optionalParameterTypes ')' | |
498 normalParameterTypes: // NEW | |
499 normalParameterType (',' normalParameterType)* | |
500 normalParameterType: // NEW | |
501 type | typedIdentifier | |
502 optionalParameterTypes: // NEW | |
503 optionalPositionalParameterTypes | namedParameterTypes | |
504 optionalPositionalParameterTypes: // NEW | |
505 '[' normalParameterTypes ','? ']' | |
506 namedParameterTypes: // NEW | |
507 '{' typedIdentifier (',' typedIdentifier)* ','? '}' | |
508 typedIdentifier: // NEW | |
509 type identifier | |
510 type: // CHANGED | |
511 typeWithoutFunction | | |
512 functionType | |
513 typeWithoutFunction: // NEW | |
514 typeName typeArguments? | |
515 typeWithoutFunctionList: // NEW | |
516 typeWithoutFunction (',' typeWithoutFunction)* | |
517 mixins: // CHANGED | |
518 'with' typeWithoutFunctionList | |
519 interfaces: // CHANGED | |
520 'implements' typeWithoutFunctionList | |
521 superclass: // CHANGED | |
522 'extends' typeWithoutFunction | |
523 mixinApplication: // CHANGED | |
524 typeWithoutFunction mixins interfaces? | |
525 newExpression: // CHANGED | |
526 'new' typeWithoutFunction ('.' identifier)? arguments | |
527 constObjectExpression: // CHANGED | |
528 'const' typeWithoutFunction ('.' identifier)? arguments | |
529 redirectingFactoryConstructorSignature: // CHANGED | |
530 'const'? 'factory' identifier ('.' identifier)? | |
531 formalParameterList '=' typeWithoutFunction ('.' identifier)? | |
532 </code></pre> | |
533 <p>The syntax relies on treating <code>Function</code> as a fixed element in a f unction | |
534 type, similar to a keyword or a symbol (many languages use symbols like | |
535 <code>-></code> to mark function types).</p> | |
536 <p><em>The rationale for using this form is that it makes a function type very | |
537 similar to the header in a declaration of a function with that type: Just | |
538 replace <code>Function</code> by the name of the function, and add missing param eter | |
539 names and default values.</em></p> | |
540 <p><em>The syntax differs from the existing function type syntax | |
541 (<code>functionSignature</code>) in that the existing syntax allows the type of a | |
542 parameter to be omitted, but the new syntax allows parameter names to be | |
543 omitted. The rationale for this change is that a function type where a | |
544 parameter has a specified name and no type is very likely to be a | |
545 mistake. For instance, <code>int Function(int)</code> should not be the type of a | |
546 function that accepts an argument named "int" of type <code>dynamic</code>, it s hould | |
547 specify <code>int</code> as the parameter type and allow the name to be | |
548 unspecified. It is still possible to opt in and specify the parameter name, | |
549 which may be useful as documentation, e.g., if several arguments have the | |
550 same type.</em></p> | |
551 <p>The modification of the rule for the nonterminal <code>type</code> may cause parsing | |
552 ambiguities. We intend to handle them by the following disambiguation rule | |
553 in the parser: If the parser is at a location L where the tokens starting | |
554 at L may be a <code>type</code> or some other construct (e.g., in the body of a | |
555 method, when parsing something that may be a statement and may also be a | |
556 declaration), the parser can commit to parsing a type by detecting that it | |
557 is looking at the identifier <code>Function</code> followed by <code><</code> or <code>(</code>, or that it | |
558 is looking at a type followed by the identifier <code>Function</code> followed b y <code><</code> | |
559 or <code>(</code>.</p> | |
560 <p><em>Note that this disambiguation rule does require parsers to have unlimited | |
561 lookahead. However, if a "diet parsing" strategy is used where the token | |
562 stream already contains references from each opening bracket (such as <code>< </code> | |
563 or <code>(</code>) to the corresponding closing bracket then the decision can be | |
564 taken in a fixed number of steps: If the current token is <code>Function</code> then | |
565 check the immediate successor (<code><</code> or <code>(</code> means yes, we are looking at | |
566 a <code>type</code>, everything else means no) and we're done; if the first toke n is | |
567 an <code>identifier</code> other than <code>Function</code> then we can check wh ether it is a | |
568 <code>qualified</code> by looking at no more than the two next tokens, and we ma y then | |
569 check whether the next token again is <code><</code>; if it is not then we lo ok for | |
570 <code>Function</code> and the token after that, and if it is <code><</code> t hen look for the | |
571 corresponding <code>></code> (we have now skipped a generic class type), and then | |
572 the successor to that token again must be <code>Function</code>, and we finally check | |
573 its successor (looking for <code><</code> or <code>(</code> again). This skip s over the | |
574 presumed type arguments to a generic class type without checking that they | |
575 are actually type arguments, but we conjecture that there are no | |
576 syntactically correct alternatives (for example, we conjecture that there | |
577 is no syntactically correct statement, not a declaration, starting with | |
578 <code>SomeIdentifier<...> Function(...</code> where the angle brackets are balanced).</em></p> | |
579 <p><em>Note that this disambiguation rule will prevent parsing some otherwise | |
580 correct programs. For instance, the declaration of an asynchronous function | |
581 named <code>Function</code> with an omitted return type (meaning <code>dynamic</ code>) and an | |
582 argument named <code>int</code> of type <code>dynamic</code> using <code>Functio n(int) async {}</code> will | |
583 be a parse error, because the parser will commit to parsing a type after | |
584 having seen "<code>Function(</code>" as a lookahead. However, we do not expect t hat it | |
585 will be a serious problem for developers to be unable to write such | |
586 programs.</em></p> | |
587 <h2><a id="user-content-scoping" class="anchor" href="#scoping" aria-hidden="tru e"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1 " viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0- 3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.4 5 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1. 09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></p ath></svg></a>Scoping</h2> | |
588 <p>Consider a typedef declaration as introduced by this feature, i.e., a | |
589 construct on the form</p> | |
590 <pre><code>metadata 'typedef' identifier typeParameters? '=' functionType ';' | |
591 </code></pre> | |
592 <p>This declaration introduces <code>identifier</code> into the enclosing librar y scope.</p> | |
593 <p>Consider a parameterized typedef, i.e., a construct on the form</p> | |
594 <pre><code>metadata 'typedef' identifier typeParameters '=' functionType ';' | |
595 </code></pre> | |
596 <p>Note that in this case the <code>typeParameters</code> are present, not optio nal. This | |
597 construct introduces a scope known as the <em>typedef scope</em>. Each typedef | |
598 scope is nested inside the library scope of the enclosing library. Every | |
599 formal type parameter declared by the <code>typeParameters</code> in this constr uct | |
600 introduces a type variable into its enclosing typedef scope. The typedef | |
601 scope is the current scope for the <code>typeParameters</code> themselves, and f or the | |
602 <code>functionType</code>.</p> | |
603 <p>Consider a <code>functionType</code> specifying a generic function type, i.e. , a | |
604 construct on the form</p> | |
605 <pre><code>returnType? 'Function' typeParameters parameterTypeList | |
606 </code></pre> | |
607 <p>Note again that <code>typeParameters</code> are present, not optional. This c onstruct | |
608 introduces a scope known as a <em>function type scope</em>. The function type | |
609 scope is nested inside the current scope for the associated <code>functionType</ code>. | |
610 Every formal type parameter declared by the <code>typeParameters</code> introduc es a | |
611 type variable into its enclosing function type scope. The function type | |
612 scope is the current scope for the entire <code>functionType</code>.</p> | |
613 <p><em>This implies that parameterized typedefs and function types are capable o f | |
614 specifying F-bounded type parameters, because the type parameters are in | |
615 scope in the type parameter list itself.</em></p> | |
616 <h2><a id="user-content-static-analysis" class="anchor" href="#static-analysis" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height=" 16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9 zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S1 4.5 6 13 6z"></path></svg></a>Static Analysis</h2> | |
617 <p>Consider a typedef declaration as introduced by this feature, i.e., a | |
618 construct on the form</p> | |
619 <pre><code>metadata 'typedef' identifier typeParameters? '=' functionType ';' | |
620 </code></pre> | |
621 <p>It is a compile-time error if a name <em>N</em> introduced into a library sco pe by | |
622 a typedef has an associated <code>functionType</code> which depends directly or | |
623 indirectly on <em>N</em>. It is a compile-time error if a bound on a formal type | |
624 parameter in <code>typeParameters</code> is not a type. It is a compile-time err or if | |
625 a typedef has an associated <code>functionType</code> which is not a type when | |
626 analyzed under the assumption that every identifier resolving to a formal | |
627 type parameter in <code>typeParameters</code> is a type. It is a compile-time er ror if | |
628 an instantiation <em>F<T1..Tk></em> of a parameterized typedef is mal-boun ded.</p> | |
629 <p><em>This implies that a typedef cannot be recursive. It can only introduce a | |
630 name as an alias for a type which is already expressible as a | |
631 <code>functionType</code>, or a name for a type-level function F where every | |
632 well-bounded invocation <code>F<T1..Tk></code> denotes a type which could be expressed | |
633 as a <code>functionType</code>. Following | |
634 <a href="https://en.wikipedia.org/wiki/Kind_(type_theory)">common terminology</a >, we | |
635 could say that a typedef can define entities of kind <code>*</code> and of kind | |
636 <code>* -> *</code>, and, when it is assumed that every formal type parameter of the | |
637 typedef (if any) has kind <code>*</code>, it is an error if the right hand side of the | |
638 declaration denotes an entity of any other kind than <code>*</code>; in particul ar, | |
639 declarations of entities of kind <code>* -> *</code> cannot be curried.</em>< /p> | |
640 <p>It is a compile-time error if a name declared in a typedef, with or without | |
641 actual type arguments, is used as a superclass, superinterface, or mixin.</p> | |
642 <h2><a id="user-content-dynamic-semantics" class="anchor" href="#dynamic-semanti cs" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" heig ht="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d ="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.7 2-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42- 1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3 .5S14.5 6 13 6z"></path></svg></a>Dynamic Semantics</h2> | |
643 <p>The addition of this feature does not change the dynamic semantics of | |
644 Dart.</p> | |
645 <h2><a id="user-content-changes" class="anchor" href="#changes" aria-hidden="tru e"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1 " viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0- 3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.4 5 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1. 09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></p ath></svg></a>Changes</h2> | |
646 <p>2017-Jan-04: Adjusted the grammar to require named parameter types to have | |
647 a type (previously, the type was optional).</p> | |
648 <p>2016-Dec-21: Changed the grammar to prevent the new function type syntax | |
649 in several locations (for instance, as a super class or as a mixin). The | |
650 main change in the grammar is the introduction of <code>typeWithoutFunction</cod e>.</p> | |
651 <p>2016-Dec-15: Changed the grammar to prevent the old style function types | |
652 (derived from <code>functionSignature</code> in the grammar) from occurring insi de | |
653 the new style (<code>functionType</code>).</p> | |
654 </article> | |
655 </div> | |
656 | |
657 </div> | |
658 | |
659 </div> | |
660 | |
661 | |
662 <a name="comments"></a> | |
663 <div class="discussion-timeline gist-discussion-timeline js-quote-selection- container "> | |
664 <div class="js-discussion js-socket-channel" data-channel="marked-as-read: gist:42910666"> | |
665 | |
666 | |
667 | |
668 | |
669 | |
670 <!-- Rendered timeline since 2017-01-04 03:41:57 --> | |
671 <div id="partial-timeline-marker" | |
672 class="js-timeline-marker js-updatable-content" | |
673 data-url="/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa/show_partial?partial=g ist%2Ftimeline_marker&since=1483530117" | |
674 data-last-modified="Wed, 04 Jan 2017 11:41:57 GMT" | |
675 > | |
676 </div> | |
677 | |
678 | |
679 <div class="discussion-timeline-actions"> | |
680 <div class="flash flash-warn mt-3"> | |
681 <a href="/join?source=comment-gist" class="btn btn-primary" rel="nofollow">S ign up for free</a> | |
682 <strong>to join this conversation on GitHub</strong>. | |
683 Already have an account? | |
684 <a href="/login?return_to=https%3A%2F%2Fgist.github.com%2Feernstg%2Fffc7bd28 1974e9018f10f0cb6cfee4aa" rel="nofollow">Sign in to comment</a> | |
685 </div> | |
686 | |
687 </div> | |
688 </div> | |
689 </div> | |
690 </div> | |
691 </div> | |
692 | |
693 <div class="modal-backdrop js-touch-events"></div> | |
694 </div><!-- /.container --> | |
695 | |
696 </div> | |
697 </div> | |
698 | |
699 </div> | |
700 | |
701 <div class="container site-footer-container"> | |
702 <div class="site-footer" role="contentinfo"> | |
703 <ul class="site-footer-links float-right"> | |
704 <li><a href="https://github.com/contact" data-ga-click="Footer, go to co ntact, text:contact">Contact GitHub</a></li> | |
705 <li><a href="https://developer.github.com" data-ga-click="Footer, go to ap i, text:api">API</a></li> | |
706 <li><a href="https://training.github.com" data-ga-click="Footer, go to tra ining, text:training">Training</a></li> | |
707 <li><a href="https://shop.github.com" data-ga-click="Footer, go to shop, t ext:shop">Shop</a></li> | |
708 <li><a href="https://github.com/blog" data-ga-click="Footer, go to blog, text:blog">Blog</a></li> | |
709 <li><a href="https://github.com/about" data-ga-click="Footer, go to abou t, text:about">About</a></li> | |
710 | |
711 </ul> | |
712 | |
713 <a href="https://github.com" aria-label="Homepage" class="site-footer-mark" title="GitHub"> | |
714 <svg aria-hidden="true" class="octicon octicon-mark-github" height="24" ve rsion="1.1" viewBox="0 0 16 16" width="24"><path fill-rule="evenodd" d="M8 0C3.5 8 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1 .49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.6 3-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64 -.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82. 64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.9 2.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8- 8z"/></svg> | |
715 </a> | |
716 <ul class="site-footer-links"> | |
717 <li>© 2017 <span title="0.21418s from github-fe134-cp1-prd.iad.github .net">GitHub</span>, Inc.</li> | |
718 <li><a href="https://github.com/site/terms" data-ga-click="Footer, go to terms, text:terms">Terms</a></li> | |
719 <li><a href="https://github.com/site/privacy" data-ga-click="Footer, go to privacy, text:privacy">Privacy</a></li> | |
720 <li><a href="https://github.com/security" data-ga-click="Footer, go to s ecurity, text:security">Security</a></li> | |
721 <li><a href="https://status.github.com/" data-ga-click="Footer, go to st atus, text:status">Status</a></li> | |
722 <li><a href="https://help.github.com" data-ga-click="Footer, go to help, text:help">Help</a></li> | |
723 </ul> | |
724 </div> | |
725 </div> | |
726 | |
727 | |
728 | |
729 | |
730 | |
731 <div id="ajax-error-message" class="ajax-error-message flash flash-error"> | |
732 <svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1 .1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M8.865 1.52c-.18 -.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h1 3.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h- 2V6h2v4z"/></svg> | |
733 <button type="button" class="flash-close js-flash-close js-ajax-error-dismis s" aria-label="Dismiss error"> | |
734 <svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1 " viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75- 1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg> | |
735 </button> | |
736 You can't perform that action at this time. | |
737 </div> | |
738 | |
739 | |
740 <script crossorigin="anonymous" src="https://assets-cdn.github.com/assets/co mpat-8a4318ffea09a0cdb8214b76cf2926b9f6a0ced318a317bed419db19214c690d.js"></scri pt> | |
741 <script crossorigin="anonymous" src="https://assets-cdn.github.com/assets/fr ameworks-6d109e75ad8471ba415082726c00c35fb929ceab975082492835f11eca8c07d9.js"></ script> | |
742 <script async="async" crossorigin="anonymous" src="https://assets-cdn.github .com/assets/github-55316b70ec9eb5a4dd5cd168f8f8da4d5fe20c53564512dd5aace9898aed7 0c5.js"></script> | |
743 | |
744 | |
745 | |
746 | |
747 <div class="js-stale-session-flash stale-session-flash flash flash-warn flash- banner d-none"> | |
748 <svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1 .1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M8.865 1.52c-.18 -.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h1 3.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h- 2V6h2v4z"/></svg> | |
749 <span class="signed-in-tab-flash">You signed in with another tab or window. <a href="">Reload</a> to refresh your session.</span> | |
750 <span class="signed-out-tab-flash">You signed out in another tab or window. <a href="">Reload</a> to refresh your session.</span> | |
751 </div> | |
752 <div class="facebox" id="facebox" style="display:none;"> | |
753 <div class="facebox-popup"> | |
754 <div class="facebox-content" role="dialog" aria-labelledby="facebox-header" aria-describedby="facebox-description"> | |
755 </div> | |
756 <button type="button" class="facebox-close js-facebox-close" aria-label="Clo se modal"> | |
757 <svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1 " viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75- 1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg> | |
758 </button> | |
759 </div> | |
760 </div> | |
761 | |
762 | |
763 </body> | |
764 </html> | |
765 | |
OLD | NEW |