|
136 | 136 | \newcommand{\Case}[1]{\textbf{Case }$\langle\hspace{0.1em}${#1}$\hspace{0.1em}\rangle$\textbf{.}}
|
137 | 137 | \newcommand{\EndCase}{\mbox{}\hfill$\scriptscriptstyle\Box$\xspace}
|
138 | 138 |
|
| 139 | +% Used for source code examples. |
139 | 140 | \newenvironment{dartCode}[1][!ht]{%
|
140 | 141 | \def\@programcr{\@addfield\strut}%
|
141 | 142 | \let\\=\@programcr%
|
|
144 | 145 | \vspace{1em}%
|
145 | 146 | }{\normalcolor\vspace{1em}}
|
146 | 147 |
|
| 148 | +% Used for normative code snippets (mainly desugaring). |
147 | 149 | \newenvironment{normativeDartCode}[1][!ht]{%
|
148 | 150 | \def\@programcr{\@addfield\strut}%
|
149 | 151 | \let\\=\@programcr%
|
|
152 | 154 | \vspace{1em}%
|
153 | 155 | }{\normalcolor\vspace{1em}}
|
154 | 156 |
|
| 157 | +% Used for meta-level code, such as the code transformations used |
| 158 | +% to specify the semantics of "null shorting" in expressions like |
| 159 | +% `a?.b.c`. |
155 | 160 | \newenvironment{metaLevelCode}[1][!ht]{%
|
156 | 161 | \def\@programcr{\@addfield\strut}%
|
157 | 162 | \let\\=\@programcr%
|
|
206 | 211 | \newcommand{\PairList}[4]{\ensuremath{%
|
207 | 212 | {#1}_{#3}\ {#2}_{#3},\,\ldots,\ {#1}_{#4}\ {#2}_{#4}}}
|
208 | 213 |
|
209 |
| -% Used to specify named arguments. |
210 |
| -% Parameters: Parameter name, argument name, index at start, index at end. |
| 214 | +% A sequence of labeled arguments with the same label and expression, |
| 215 | +% only differing by subscript. |
| 216 | +% Parameters: Argument label, argument expression, start index, |
| 217 | +% end index. |
| 218 | +% |
| 219 | +% For example, \NamedArgumentList{n}{e}{1}{k} yields approximately |
| 220 | +% "n1: e1, n2: e2, ... nk: ek". |
211 | 221 | \newcommand{\NamedArgumentList}[4]{\PairList{#1}{\!\!:\,\,{#2}}{#3}{#4}}
|
212 | 222 |
|
213 |
| -% Used to specify an argument list including positional and named arguments. |
214 |
| -% Parameters: Argument name, number of positional arguments, named parameter |
215 |
| -% name, number of named arguments. |
| 223 | +% A sequence of unlabeled and labeled arguments with the same expression and |
| 224 | +% (for all labeled arguments) the same label, only differing by subscript. |
| 225 | +% Parameters: Argument name, number of positional arguments, labeled parameter |
| 226 | +% label, number of labeled arguments. |
| 227 | +% |
| 228 | +% For example, \ArgumentList{a}{n}{x}{k} yields approximately |
| 229 | +% "a1, .. an, xn+1: an+1, .. xn+k: an+k". |
216 | 230 | \newcommand{\ArgumentList}[4]{%
|
217 | 231 | \List{#1}{1}{#2},\ \NamedArgumentList{#3}{#1}{{#2}+1}{{#2}+{#4}}}
|
218 | 232 |
|
219 |
| -% Used to specify a standard argument list. |
| 233 | +% Used to specify a standard argument list, that is, an argument list |
| 234 | +% which uses the symbols that we prefer to use for that purpose |
| 235 | +% whenever possible. |
| 236 | +% |
| 237 | +% Approximately "a1 .. an, xn+1: an+1 .. xn+k: an+k". |
220 | 238 | \newcommand{\ArgumentListStd}{\ArgumentList{a}{n}{x}{k}}
|
221 | 239 |
|
222 |
| -% Used to specify a standard type argument list. |
| 240 | +% Used to specify a standard type argument list, that is, a type |
| 241 | +% argument list which uses the symbols we prefer to use for that |
| 242 | +% purpose whenever possible. |
| 243 | +% |
| 244 | +% Approximately "A1 .. Ar". |
223 | 245 | \newcommand{\TypeArgumentListStd}{\List{A}{1}{r}}
|
224 | 246 |
|
225 | 247 | % Used to specify a list of tuples of the form $(K_j, V_j)$ which are
|
|
256 | 278 | \newcommand{\TypeParametersNoBounds}[2]{\ensuremath{%
|
257 | 279 | {#1}_1\,\EXTENDS\,\ldots,\ \ldots,\ {#1}_{#2}\,\EXTENDS\,\ldots}}
|
258 | 280 |
|
259 |
| -% For consistency, we may as well use this whenever possible. |
| 281 | +% Used to specify a standard type parameter list, that is, a type |
| 282 | +% parameter declaration list which uses the symbols we prefer to use |
| 283 | +% for that purpose whenever possible. |
| 284 | +% |
| 285 | +% Approximately "X1 extends B1, .. Xs extends Bs". |
260 | 286 | \newcommand{\TypeParametersStd}{\TypeParameters{X}{B}{s}}
|
261 | 287 |
|
262 | 288 | % Used to specify comma separated lists of pairs of symbols
|
|
288 | 314 |
|
289 | 315 | % Used to specify function type parameter lists with positional optionals.
|
290 | 316 | % Arguments: Parameter type, number of required parameters,
|
291 |
| -% number of optional parameters. |
292 |
| -\newcommand{\FunctionTypePositionalArguments}[3]{% |
| 317 | +% number of optional parameters. |
| 318 | +% |
| 319 | +% For example, \FunctionTypePositionalParameters{T}{n}{k} yields |
| 320 | +% approximately "T1, .. Tn, [Tn+1, .. Tn+k]". |
| 321 | +\newcommand{\FunctionTypePositionalParameters}[3]{% |
293 | 322 | \List{#1}{1}{#2},\ [\List{#1}{{#2}+1}{{#2}+{#3}}]}
|
294 | 323 |
|
295 |
| -\newcommand{\FunctionTypePositionalArgumentsStd}{% |
296 |
| - \FunctionTypePositionalArguments{T}{n}{k}} |
| 324 | +% Used to specify a standard positional function type, that is, a function |
| 325 | +% type with positional optional parameters which uses the symbols we prefer |
| 326 | +% to use for that purpose whenever possible. |
| 327 | +% |
| 328 | +% Approximately "T1, .. Tn, [Tn+1, .. Tn+k]". |
| 329 | +\newcommand{\FunctionTypePositionalParametersStd}{% |
| 330 | + \FunctionTypePositionalParameters{T}{n}{k}} |
| 331 | + |
| 332 | +% Used to specify function type parameter lists with named optionals. |
| 333 | +% Arguments: Parameter type, number of required parameters, |
| 334 | +% name of optional parameters, number of optional parameters. |
| 335 | +% |
| 336 | +% For example \FunctionTypeNamedParameters{T}{n}{x}{k}{r} yields approximately |
| 337 | +% "T1, .. Tn, {rn+1 Tn+1 xn+1, .. rn+k Tn+k xn+k}". |
| 338 | +\newcommand{\FunctionTypeNamedParameters}[5]{% |
| 339 | + \List{#1}{1}{#2},\ \{\TripleList{#5}{#1}{#3}{{#2}+1}{{#2}+{#4}}\}} |
| 340 | + |
| 341 | +% Variant of \FunctionTypeNamedParameters that uses the standard symbols, |
| 342 | +% that is, a list of function type parameter declarations with named |
| 343 | +% parameters which uses the symbols that we prefer to use for that purpose |
| 344 | +% whenever possible. |
| 345 | +% |
| 346 | +% Approximately "T1, .. Tn, {rn+1 Tn+1 xn+1, .. rn+k Tn+k xn+k}". |
| 347 | +\newcommand{\FunctionTypeNamedParametersStd}{% |
| 348 | + \FunctionTypeNamedParameters{T}{n}{x}{k}{r}} |
297 | 349 |
|
298 | 350 | % Used to specify function types with positional optionals:
|
299 | 351 | % Arguments: Return type, spacer, type parameter name, bound name,
|
300 | 352 | % number of type parameters, parameter type, number of required parameters,
|
301 | 353 | % number of optional parameters.
|
| 354 | +% |
| 355 | +% For example, \FunctionTypePositional{R}{ }{X}{B}{s}{T}{n}{k} yields |
| 356 | +% approximately |
| 357 | +% "R Function<X1 extends B1, .. Xs extends Bs>(T1, .. Tn, [Tn+1, .. Tn+k])". |
302 | 358 | \newcommand{\FunctionTypePositional}[8]{%
|
303 | 359 | \FunctionType{#1}{#2}{#3}{#4}{#5}{%
|
304 |
| - \FunctionTypePositionalArguments{#6}{#7}{#8}}} |
| 360 | + \FunctionTypePositionalParameters{#6}{#7}{#8}}} |
305 | 361 |
|
306 | 362 | % Same as \FunctionTypePositional except suitable for inline usage,
|
307 | 363 | % hence omitting the spacer argument.
|
308 | 364 | \newcommand{\RawFunctionTypePositional}[7]{%
|
309 | 365 | \RawFunctionType{#1}{#2}{#3}{#4}{%
|
310 |
| - \FunctionTypePositionalArguments{#5}{#6}{#7}}} |
| 366 | + \FunctionTypePositionalParameters{#5}{#6}{#7}}} |
| 367 | + |
| 368 | +% A variant of \FunctionTypePositional that uses the standard symbols, |
| 369 | +% that is, a function type with positional optional parameters which |
| 370 | +% uses the symbols that we prefer to use for that purpose whenever |
| 371 | +% possible. |
| 372 | +% |
| 373 | +% For example, \FunctionTypePositionalStd{R} yields approximately |
| 374 | +% "R Function<X1 extends B1, .. Xs extends Bs>(T1, T2, .. Tn, [Tn+1 .. Tn+k])". |
| 375 | +\newcommand{\FunctionTypePositionalStd}[1]{% |
| 376 | + \FunctionTypePositional{#1}{ }{X}{B}{s}{T}{n}{k}} |
311 | 377 |
|
312 |
| -% Used to specify function type parameter lists with named optionals. |
313 |
| -% Arguments: Parameter type, number of required parameters, |
314 |
| -% name of optional parameters, number of optional parameters, |
315 |
| -% name of `required` symbol. |
316 |
| -\newcommand{\FunctionTypeNamedArguments}[5]{% |
317 |
| - \List{#1}{1}{#2},\ \{\TripleList{#5}{#1}{#3}{{#2}+1}{{#2}+{#4}}\}} |
318 |
| - |
319 |
| -\newcommand{\FunctionTypeNamedArgumentsStd}{% |
320 |
| - \FunctionTypeNamedArguments{T}{n}{x}{k}{r}} |
| 378 | +% Same as \FunctionTypePositionalStd except suitable for inline usage, |
| 379 | +% hence omitting the spacer argument. |
| 380 | +\newcommand{\RawFunctionTypePositionalStd}[1]{% |
| 381 | + \RawFunctionTypePositional{#1}{X}{B}{s}{T}{n}{k}} |
| 382 | + |
| 383 | +% Same as \FunctionTypePositionalStd except that it includes a newline, hence |
| 384 | +% suitable for function types that are too long to fit in one line. |
| 385 | +\newcommand{\FunctionTypePositionalStdCr}[1]{% |
| 386 | + \FunctionTypePositional{#1}{\\}{X}{B}{s}{T}{n}{k}} |
321 | 387 |
|
322 | 388 | % Used to specify function types with named parameters:
|
323 | 389 | % Arguments: Return type, spacer, type parameter name, bound name,
|
324 | 390 | % number of type parameters, parameter type, number of required parameters,
|
325 |
| -% name of optional parameters, number of optional parameters, |
326 |
| -% name of `required` symbol. |
| 391 | +% name of optional parameters, number of optional parameters. |
| 392 | +% The name of the `required` symbol is always `r` (because we can't have |
| 393 | +% 10 arguments in a LaTeX command, and `r` is always OK in practice). |
| 394 | +% |
| 395 | +% For example, \FunctionTypeNamed{R}{ }{X}{B}{s}{T}{n}{x}{k} yields |
| 396 | +% approximately "R Function<X1 extends B1, .. Xs extends Bs>( |
| 397 | +% T1, T2, .. Tn, {rn+1 Tn+1 xn+1, .. rn+k Tn+k xn+k])". |
327 | 398 | \newcommand{\FunctionTypeNamed}[9]{%
|
328 | 399 | \FunctionType{#1}{#2}{#3}{#4}{#5}{\\
|
329 |
| - \mbox{}\qquad\FunctionTypeNamedArguments{#6}{#7}{#8}{#9}{#10}}} |
| 400 | + \mbox{}\qquad\FunctionTypeNamedParameters{#6}{#7}{#8}{#9}{r}}} |
330 | 401 |
|
331 |
| -% Same as \FunctionType except suitable for inline usage, hence omitting |
| 402 | +% Same as \FunctionTypeNamed except suitable for inline usage, hence omitting |
332 | 403 | % the spacer argument.
|
333 |
| -\newcommand{\RawFunctionTypeNamed}[9]{% |
| 404 | +\newcommand{\RawFunctionTypeNamed}[8]{% |
334 | 405 | \RawFunctionType{#1}{#2}{#3}{#4}{%
|
335 |
| - \FunctionTypeNamedArguments{#5}{#6}{#7}{#8}{#9}}} |
| 406 | + \FunctionTypeNamedParameters{#5}{#6}{#7}{#8}{r}}} |
| 407 | + |
| 408 | +% A variant of \FunctionTypeNamed that uses the standard symbols, |
| 409 | +% that is, a function type with positional optional parameters which |
| 410 | +% uses the symbols that we prefer to use for that purpose whenever |
| 411 | +% possible. |
| 412 | +% |
| 413 | +% For example, \FunctionTypeNamedStd{R} yields approximately |
| 414 | +% "R Function<X1 extends B1, .. Xs extends Bs>( |
| 415 | +% T1, T2, .. Tn, {rn+1 Tn+1 xn+1, .. rn+k Tn+k xn+k})". |
| 416 | +\newcommand{\FunctionTypeNamedStd}[1]{% |
| 417 | + \FunctionTypeNamed{#1}{ }{X}{B}{s}{T}{n}{x}{k}} |
| 418 | + |
| 419 | +% Same as \FunctionTypeNamedStd except suitable for inline usage, hence |
| 420 | +% omitting the spacer argument. |
| 421 | +\newcommand{\RawFunctionTypeNamedStd}[1]{% |
| 422 | + \RawFunctionTypeNamed{#1}{X}{B}{s}{T}{n}{x}{k}{r}} |
| 423 | + |
| 424 | +% Same as \FunctionTypeNamedStd except that it includes a newline, hence |
| 425 | +% suitable for function types that are too long to fit in one line. |
| 426 | +\newcommand{\FunctionTypeNamedStdCr}[1]{% |
| 427 | + \FunctionTypeNamed{#1}{\\}{X}{B}{s}{T}{n}{x}{k}} |
336 | 428 |
|
337 | 429 | % Used to specify function types with no optional parameters:
|
338 | 430 | % Arguments: Return type, spacer, type parameter name, bound name,
|
339 | 431 | % number of type parameters, parameter type,
|
340 | 432 | % number of parameters (all required).
|
| 433 | +% |
| 434 | +% For example, \FunctionTypeAllRequired{R}{ }{X}{B}{s}{T}{n} yields |
| 435 | +% approximately "R Function<X1 extends B1, .. Xs extends Bs>(T1, T2, .. Tn)". |
341 | 436 | \newcommand{\FunctionTypeAllRequired}[7]{%
|
342 | 437 | \FunctionType{#1}{#2}{#3}{#4}{#5}{\List{#6}{1}{#7}}}
|
343 | 438 |
|
344 |
| -\newcommand{\FunctionTypePositionalStd}[1]{% |
345 |
| - \FunctionTypePositional{#1}{ }{X}{B}{s}{T}{n}{k}} |
346 |
| - |
347 |
| -\newcommand{\RawFunctionTypePositionalStd}[1]{% |
348 |
| - \RawFunctionTypePositional{#1}{X}{B}{s}{T}{n}{k}} |
349 |
| - |
350 |
| -\newcommand{\FunctionTypeNamedStd}[1]{% |
351 |
| - \FunctionTypeNamed{#1}{ }{X}{B}{s}{T}{n}{x}{k}{r}} |
352 |
| - |
353 |
| -\newcommand{\RawFunctionTypeNamedStd}[1]{% |
354 |
| - \RawFunctionTypeNamed{#1}{X}{B}{s}{T}{n}{x}{k}{r}} |
355 |
| - |
| 439 | +% A variant of \FunctionTypeAllRequired that uses the standard symbols, |
| 440 | +% that is, a function type with positional optional parameters which |
| 441 | +% uses the symbols that we prefer to use for that purpose whenever |
| 442 | +% possible. |
| 443 | +% |
| 444 | +% For example, \FunctionTypeAllRequiredStd{R} yields approximately |
| 445 | +% "R Function<X1 extends B1, .. Xs extends Bs>(T1, T2, .. Tn)". |
356 | 446 | \newcommand{\FunctionTypeAllRequiredStd}[1]{%
|
357 | 447 | \FunctionTypeAllRequired{#1}{ }{X}{B}{s}{T}{n}}
|
358 | 448 |
|
359 |
| -\newcommand{\FunctionTypePositionalStdCr}[1]{% |
360 |
| - \FunctionTypePositional{#1}{\\}{X}{B}{s}{T}{n}{k}} |
361 |
| - |
362 |
| -\newcommand{\FunctionTypeNamedStdCr}[1]{% |
363 |
| - \FunctionTypeNamed{#1}{\\}{X}{B}{s}{T}{n}{x}{k}{r}} |
364 |
| - |
365 |
| -\newcommand{\FunctionTypeNamedStdArgCr}[1]{% |
366 |
| - \FunctionTypeNamedArgCr{#1}{ }{X}{B}{s}{T}{n}{x}{k}{r}} |
367 |
| - |
| 449 | +% Same as \FunctionTypeAllRequiredStd except that it includes a newline, hence |
| 450 | +% suitable for function types that are too long to fit in one line. |
368 | 451 | \newcommand{\FunctionTypeAllRequiredStdCr}[1]{%
|
369 | 452 | \FunctionTypeAllRequired{#1}{\\}{X}{B}{s}{T}{n}}
|
370 | 453 |
|
|
0 commit comments