Changeset 29
- Timestamp:
- Nov 23, 2007, 2:59:25 PM (18 years ago)
- Author:
- ats
- Message:
-
Various bits of rework.
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/trunk/200711-tock-seminars/200711-tock-slides.tex
r28 r29 11 11 \usepackage{pifont} 12 12 \usepackage{xspace} 13 (削除) \def\occam{{occam\xspace}} (削除ここまで)14 (削除) \def\occampi{{occam-\Pisymbol{psy}{112}}\xspace} (削除ここまで)15 13 16 14 \mode<presentation> 17 15 { 18 \usetheme{ (削除) Rochester (削除ここまで)}16 \usetheme{(追記) JuanLesPins (追記ここまで)} 19 17 \usecolortheme[named=KentBlue]{structure} 20 18 \setbeamercovered{transparent} 21 19 } 22 (削除) (削除ここまで)23 20 24 21 \usepackage[english]{babel} … … 37 34 38 35 \author{Neil Brown and Adam Sampson} 39 \institute (削除) [Universities of Somewhere and Elsewhere] % (optional, but mostly needed) (削除ここまで)36 \institute(追記) (追記ここまで) 40 37 { 41 38 Computing Laboratory\\ … … 99 96 } 100 97 101 \def\ (削除) occam (削除ここまで)settings{98 \def\(追記) rain (追記ここまで)settings{ 102 99 \lstset{ 103 language={ (削除) [21]occam (削除ここまで)},100 language={(追記) c (追記ここまで)}, 104 101 columns=fixed, 105 102 basicstyle=\small\ttfamily, 103 (追記) emphstyle=\color{KentBlue}\bfseries, (追記ここまで) 106 104 keywordstyle=\color{KentBlue}\bfseries, 107 105 identifierstyle=, … … 111 109 } 112 110 111 (追記) \def\occamsettings{ (追記ここまで) 112 (追記) \lstset{ (追記ここまで) 113 (追記) language={[21]occam}, (追記ここまで) 114 (追記) columns=fixed, (追記ここまで) 115 (追記) basicstyle=\small\ttfamily, (追記ここまで) 116 (追記) emphstyle=\color{KentBlue}\bfseries, (追記ここまで) 117 (追記) keywordstyle=\color{KentBlue}\bfseries, (追記ここまで) 118 (追記) identifierstyle=, (追記ここまで) 119 (追記) commentstyle=\color{KentGreen}\itshape, (追記ここまで) 120 (追記) stringstyle=, (追記ここまで) 121 (追記) showstringspaces=false} (追記ここまで) 122 (追記) } (追記ここまで) 123 (追記) (追記ここまで) 113 124 \begin{document} 114 125 … … 153 164 \item In 2007, it was becoming increasingly clear that we needed 154 165 a new occam compiler\ldots 155 \item Adam wrote the initial (削除) \ (削除ここまで)occam-to-C Tock166 \item Adam wrote the initial (追記) (追記ここまで)occam-to-C Tock 156 167 \begin{itemize} 157 168 \item Based on FCO ``spike solution'' compiler … … 171 182 \item Multiple frontends 172 183 \begin{itemize} 173 \item occam (削除) 2.1 (soon to be \occampi) (削除ここまで)184 \item occam(追記) 2.1 (追記ここまで) 174 185 \item Rain 175 186 \end{itemize} … … 187 198 \frametitle{An extensible compiler} 188 199 \begin{itemize} 189 \item (削除) \occampi (削除ここまで)is very much still under development200 \item (追記) occam (追記ここまで) is very much still under development 190 201 \item We want to experiment with new language and runtime 191 202 features … … 194 205 \item Our students know Haskell (in theory) 195 206 \end{itemize} 196 (削除) \end{itemize} (削除ここまで)197 (削除) \end{frame} (削除ここまで)198 (削除) (削除ここまで)199 (削除) \begin{frame} (削除ここまで)200 (削除) \frametitle{Why \occampi is interesting} (削除ここまで)201 (削除) \begin{itemize} (削除ここまで)202 (削除) \item Parallelism! (削除ここまで)203 (削除) \item Indentation-based syntax (削除ここまで)204 (削除) \item Parser needs lots of lookahead (削除ここまで)205 (削除) \item Compile-time usage checks (削除ここまで)206 (削除) \begin{itemize} (削除ここまで)207 (削除) \item Parallel safety (削除ここまで)208 (削除) \item Definedness (削除ここまで)209 (削除) \end{itemize} (削除ここまで)210 (削除) \item Abbreviations (削除ここまで)211 207 \end{itemize} 212 208 \end{frame} … … 317 313 \end{frame} 318 314 319 \begin{frame} 320 \frametitle{Problems with generics} 321 \framesubtitle{Digging too deep} 315 \subsection{Problems with generics} 316 317 \begin{frame} 318 \frametitle{Digging too deep} 322 319 \begin{itemize} 323 320 \item \lstinline|everywhere| really does look \emph{everywhere} … … 338 335 339 336 \begin{frame} 340 \frametitle{Problems with generics} 341 \framesubtitle{Looking at things in the wrong order} 337 \frametitle{Looking at things in the wrong order} 342 338 \begin{itemize} 343 339 \item Sometimes \lstinline|everywhere| is not the traversal we want … … 345 341 \item e.g. we only want the outermost part of a 346 342 recursive type \\ 347 % FIXME: emph first Par 348 \lstinline|Par (Par a b) (Par c d)| 343 \lstset{emph={Par}}\lstinline|Par|\lstset{emph={}} \lstinline|(Par a b) (Par c d)| 349 344 \end{itemize} 350 345 \item No problem … … 357 352 358 353 \begin{frame}[fragile] 359 \frametitle{Problems with generics} 360 \framesubtitle{Well, \emph{nearly} any type\ldots} 354 \frametitle{Well, \emph{nearly} any type\ldots} 361 355 \begin{itemize} 362 356 \item \lstinline|Data.Generics| has some limitations … … 376 370 \section{Testing} 377 371 378 \begin{frame} 379 \frametitle{Testing frameworks} 372 \subsection{Testing frameworks} 373 374 \begin{frame} 375 \frametitle{The frameworks we use} 380 376 \begin{itemize} 381 377 \item HUnit … … 396 392 397 393 \begin{frame}[fragile] 398 \frametitle{ (削除) Testing Frameworks Example (削除ここまで)s}394 \frametitle{(追記) Some example test (追記ここまで)s} 399 395 \begin{lstlisting} 400 396 -- HUnit example: 401 (assertEqual "Test 0") "foo_bar" (cStyleNames "foo.bar") 397 assertEqual "Test 0" 398 "foo_bar" 399 (cStyleNames "foo.bar") 402 400 403 401 -- QuickCheck example: … … 409 407 = check (execRandom (seed n) (randList (n/10))) 410 408 where 411 check ns = (all ( (削除) \x -> x (削除ここまで)> 0) ns) && (sum ns == n)409 check ns = (all ((追記) (追記ここまで)> 0) ns) && (sum ns == n) 412 410 \end{lstlisting} 413 411 \end{frame} 414 412 %TODO consider replacing the above QuickCheck example with a simpler one 415 413 416 \begin{frame} 417 \frametitle{Writing tests} 418 \begin{itemize} 419 \item When testing the complex output of a function 420 \begin{itemize} 421 \item May want to ignore some of the output because it's 422 unpredictable or of no concern 423 \begin{itemize} 424 \item e.g. source positions when testing the parser 425 \item e.g. nonce names 426 \end{itemize} 427 \item May want to check that parts of the output match 428 \begin{itemize} 429 \item e.g. is this variable the same as that variable? 430 \end{itemize} 431 \item Want to avoid having duplicate code 432 \end{itemize} 433 \end{itemize} 434 %FIXME: Split this up among the following slides 435 \end{frame} 414 \subsection{Pattern-matching for tests} 436 415 437 416 \begin{frame}[fragile] 438 417 \frametitle{Ignoring elements} 439 \begin{verbatim} 418 Some items in the AST can be ignored when testing 419 \begin{itemize} 420 \item e.g. source positions from the parser 421 \end{itemize} 422 \rainsettings 423 \begin{lstlisting} 440 424 if (a) { } 441 \end{verbatim} 425 \end{lstlisting} 426 427 parses as: 428 \haskellsettings 429 \lstset{emph={Pos}} 442 430 \begin{lstlisting} 443 431 If 444 432 (Pos 0) 445 433 (Expr (Pos 4) (JustVar "a")) 446 (Block (Pos 7) [ (削除) (削除ここまで)])447 \end{lstlisting} (削除) (削除ここまで)448 %FIXME: Explain what Pos is (in description above anyway) 434 (Block (Pos 7) [(追記) (追記ここまで)]) 435 \end{lstlisting}(追記) (追記ここまで) 436 \lstset{emph={}} 449 437 \end{frame} 450 438 451 439 \begin{frame}[fragile] 452 440 \frametitle{Ignoring elements} 453 \begin{lstlisting} 454 (assertEqual "If Test 0") 455 (If (Pos 0) (Expr (Pos 4) (JustVar "a")) (Block (Pos 7) [ ])) 456 (parse "if (a) { }") 457 458 (assertBool "If Test 0") (checkIfTest0 (parse "if (a) { }")) 441 Could match the output exactly: 442 \begin{lstlisting} 443 assertEqual "If Test 0" 444 (If (Pos 0) (Expr (Pos 4) (JustVar "a")) (Block (Pos 7) [])) 445 (parse "if (a) { }") 446 \end{lstlisting} 447 448 But it's more robust to use a pattern match: 449 \begin{lstlisting} 450 assertBool "If Test 0" (checkIfTest0 (parse "if (a) { }")) 459 451 where 460 452 checkIfTest0 461 453 (If _ 462 454 (Expr _ (JustVar "a")) 463 (Block _ [ (削除) (削除ここまで)])455 (Block _ [(追記) (追記ここまで)]) 464 456 ) = True 465 457 checkIfTest0 _ = False … … 468 460 469 461 \begin{frame}[fragile] 470 \frametitle{Matching elements} 462 \frametitle{Avoiding duplicate code} 463 464 Testing that a pass generates the correct code to swap two variables: 471 465 \occamsettings 472 466 \begin{lstlisting} 473 x, y := y, x 474 475 t := y 467 temp42 := y 476 468 y := x 477 x := t 478 \end{lstlisting} 469 x := temp42 470 \end{lstlisting} 471 472 This has to be matched as: 479 473 \haskellsettings 480 474 \begin{lstlisting} 481 Assign p0 (VarList p0 ["x", "y"]) (ExprList p0 [JustVar "x", JustVar "y"]) 482 483 Block p0 484 [ Assign p0 (VarList p0 ["t"]) (ExprList p0 [JustVar "y"]) 485 , Assign p0 (VarList p0 ["y"]) (ExprList p0 [JustVar "x"]) 486 , Assign p0 (VarList p0 ["x"]) (ExprList p0 [JustVar "t"]) 475 Block 476 [ Assign (VarList ["temp42"]) (ExprList [JustVar "y"]) 477 , Assign (VarList ["y"]) (ExprList [JustVar "x"]) 478 , Assign (VarList ["x"]) (ExprList [JustVar "temp42"]) 487 479 ] 488 489 p0 = Pos 0 490 \end{lstlisting} 491 %FIXME: More explanation 492 \end{frame} 493 494 \begin{frame}[fragile] 495 \frametitle{Matching elements} 496 \begin{lstlisting} 497 (assertEqual "tempAssignTest 0") 498 (Block p0 499 [ singleAssign "t" "y" 480 \end{lstlisting} 481 \end{frame} 482 483 \begin{frame}[fragile] 484 \frametitle{Avoiding duplicate code} 485 We can remove some of the duplication using a helper function: 486 487 \begin{lstlisting} 488 assertEqual "tempAssignTest 0" 489 (Block 490 [ singleAssign "temp42" "y" 500 491 , singleAssign "y" "x" 501 , singleAssign "x" "t (削除) (削除ここまで)"492 , singleAssign "x" "t(追記) emp42 (追記ここまで)" 502 493 ]) 503 494 testOutput 504 495 505 496 singleAssign lhv rhv 506 = Assign p0 (VarList p0 [lhv]) (ExprList p0 [JustVar rhv]) 507 \end{lstlisting} 508 %FIXME: Say "tmp42" or something instead of "t" here, to make it clear 509 %it's a nonce? 510 \end{frame} 511 512 \begin{frame}[fragile] 513 \frametitle{Matching elements} 497 = Assign (VarList [lhv]) (ExprList [JustVar rhv]) 498 \end{lstlisting} 499 500 But it's still got the name of the temporary hard-coded into it\ldots 501 \end{frame} 502 503 \begin{frame}[fragile] 504 \frametitle{Making sure AST elements match} 505 We don't care what the temporary variable is called -- just that it's 506 the same one that's used in both cases: 507 514 508 \begin{lstlisting} 515 509 assertBool "tempAssignTest 0" 516 510 (checktempAssignTest0 testOutput) 517 511 518 checktempAssignTest0 (Block (削除) _ (削除ここまで)519 [ Assign (削除) _ (VarList _ [tempVar0]) (ExprList _ (削除ここまで)[JustVar "y"])520 , Assign (削除) _ (VarList _ ["y"]) (ExprList _ (削除ここまで)[JustVar "x"])521 , Assign (削除) _ (VarList _ ["x"]) (ExprList _ (削除ここまで)[JustVar tempVar1])512 checktempAssignTest0 (Block(追記) (追記ここまで) 513 [ Assign (追記) (VarList [tempVar0]) (ExprList (追記ここまで) [JustVar "y"]) 514 , Assign (追記) (VarList ["y"]) (ExprList (追記ここまで) [JustVar "x"]) 515 , Assign (追記) (VarList ["x"]) (ExprList (追記ここまで) [JustVar tempVar1]) 522 516 ]) 523 517 = tempVar0 == tempVar1 524 518 checktempAssignTest0 _ = False 525 519 \end{lstlisting} 520 (追記) (追記ここまで) 521 (追記) But now we can't use our helper function any more. (追記ここまで) 526 522 \end{frame} 527 523 … … 540 536 \item But this isn't implemented yet\ldots 541 537 \end{itemize} 542 (削除) \end{itemize} (削除ここまで)543 (削除) \end{frame} (削除ここまで)544 (削除) (削除ここまで)545 (削除) \begin{frame} (削除ここまで)546 (削除) \frametitle{Pattern-matching for tests} (削除ここまで)547 (削除) \begin{itemize} (削除ここまで)548 (削除) \item We need to roll our own mechanism (削除ここまで)549 538 \item Parser combinators? 550 539 \begin{itemize} 551 540 \item Would work, but the syntax is awful 552 541 \end{itemize} 553 (削除) \item Generics (削除ここまで)554 542 \end{itemize} 555 543 \end{frame} … … 557 545 \begin{frame}[fragile] 558 546 \frametitle{Generic pattern-matching} 559 \begin{itemize} 560 \item Built on \lstinline|Data.Generics| 561 \end{itemize} 547 Built our own pattern-matching library using \lstinline|Data.Generics| 562 548 \begin{lstlisting} 563 549 type Pattern = 564 D (削除) C (削除ここまで)550 D(追記) on'tCare (追記ここまで) 565 551 | Named String Pattern 566 552 | Match Constr [Pattern] 567 553 \end{lstlisting} 568 \begin{itemize} 569 \item All \lstinline|Named| items with the same name must match 554 All \lstinline|Named| items with the same name must match 570 555 \end{itemize} 571 556 \end{frame} … … 588 573 (Pos 0) 589 574 (Expr (Pos 4) (JustVar "a")) 590 (Block (Pos 7) [ (削除) (削除ここまで)]))575 (Block (Pos 7) [(追記) (追記ここまで)])) 591 576 592 577 assertPatternMatch "If Test 0" 593 578 (mIf 594 D (削除) C (削除ここまで)595 (mExpr D (削除) C (削除ここまで)(JustVar "a"))596 (mBlock D (削除) C ([ (削除ここまで)] :: [Statement])))579 D(追記) on'tCare (追記ここまで) 580 (mExpr D(追記) on'tCare (追記ここまで) (JustVar "a")) 581 (mBlock D(追記) on'tCare ([ (追記ここまで)] :: [Statement]))) 597 582 (parse "if (a) { }") 598 583 … … 606 591 \frametitle{Generic pattern matching} 607 592 \begin{lstlisting} 608 (assertPatternMatch "tempAssignTest 0") 609 (mBlock D (削除) C (削除ここまで)610 [ singleAssign' ("tempVar" @@ D (削除) C (削除ここまで)) "y"593 assertPatternMatch "tempAssignTest 0" 594 (mBlock D(追記) on'tCare (追記ここまで) 595 [ singleAssign' ("tempVar" @@ D(追記) on'tCare (追記ここまで)) "y" 611 596 , singleAssign' "y" "x" 612 , singleAssign' "x" ("tempVar" @@ D (削除) C (削除ここまで))597 , singleAssign' "x" ("tempVar" @@ D(追記) on'tCare (追記ここまで)) 613 598 ]) 614 599 testOutput 615 600 616 singleAssign' lhv rhv = mAssign D (削除) C (削除ここまで)617 (mVarList D (削除) C (削除ここまで)[lhv])618 (mExprList D (削除) C (削除ここまで)[mJustVar rhv])601 singleAssign' lhv rhv = mAssign D(追記) on'tCare (追記ここまで) 602 (mVarList D(追記) on'tCare (追記ここまで) [lhv]) 603 (mExprList D(追記) on'tCare (追記ここまで) [mJustVar rhv]) 619 604 \end{lstlisting} 620 605 %FIXME: Point out that singleAssign' can be reused between tests … … 630 615 \item Functions are trickier 631 616 \end{itemize} 632 \item Patterns are (削除) type-checked at run-time (i.e. test-time) (削除ここまで)617 \item Patterns are (追記) checked for consistency as they're applied (追記ここまで) 633 618 \item Speed's not great 634 619 \begin{itemize} … … 641 626 %}}} 642 627 643 %{{{ control flow graphs 644 \section{Control-flow graphs} 628 %{{{ code analysis 629 \section{Code analysis} 630 631 \subsection{Tree navigation} 645 632 646 633 \begin{frame} 647 634 \frametitle{Control-flow graphs} 648 635 \begin{itemize} 649 % FIXME: this needs rewording 650 \item For simplicity of some algorithms, we looked at using a CFG 636 \item We need to analyse the AST for various purposes 637 \begin{itemize} 638 \item Parallel usage checking 639 \item Definedness checking 640 \item Type optimisation 641 \end{itemize} 642 \item Many algorithms are easier to express on a CFG than on the 643 AST directly 651 644 \item Generating the CFG from the AST is easy 652 \item Difficult to link CFG back to AST 645 \end{itemize} 646 \end{frame} 647 648 \begin{frame} 649 \frametitle{Modifying the AST} 650 \begin{itemize} 651 \item Once we've made a decision based on the CFG, we need to go 652 and change the AST 653 \item But how? 653 654 \begin{itemize} 654 655 \item No unique identifiers in AST 655 656 \item Only unique thing is the position in the tree 656 657 \item No easy way to find \emph{and modify} a particular spot 657 in a tree (削除) (using monadic modifications, too!) (削除ここまで)658 in a tree(追記) (追記ここまで) 658 659 \end{itemize} 659 660 \end{itemize} … … 662 663 \begin{frame} 663 664 \frametitle{Navigating the AST} 664 (削除) %FIXME: picture (削除ここまで)665 665 \begin{columns} 666 666 \column{.5\textwidth} … … 718 718 \end{frame} 719 719 720 %TODO I think this slide is a candidate for deletion 721 \begin{frame} 722 \frametitle{Printing out the AST} 723 \begin{itemize} 724 %FIXME: why's this useful 725 \item Use Writer-like monad that helps with indentation 726 \item Transformations can introduce AST elements that are unprintable 727 \item Could be used to test parser using QuickCheck 728 \end{itemize} 729 \includegraphics[height=30mm]{Tock-QC-Parse-AST.png} 730 \end{frame} 720 \subsection{Usage checking} 721 722 \begin{frame}[fragile] 723 \frametitle{Usage checking} 724 \begin{itemize} 725 \item Detect parallel usage of objects 726 \item Use generics to label CFG nodes with variables read/written to 727 \end{itemize} 728 \begin{lstlisting} 729 type UsedVars = ([String], [String]) -- written, read 730 731 getUsedVars (Assign _ (VarList lhvs) rhs) 732 = (lhvs, map getJustVar (listify isJustVar rhs)) 733 734 getJustVar (JustVar v) = v 735 isJustVar (JustVar _) = True 736 isJustVar _ = False 737 \end{lstlisting} 738 %FIXME: "The code snippet is short, but I worry that it is not very 739 %understandable" 740 \end{frame} 741 742 \begin{frame} 743 \frametitle{Usage checking} 744 \begin{itemize} 745 \item As in other occam compilers, array indexing makes usage checking hard 746 \item For now, this problem has been skipped 747 \end{itemize} 748 \end{frame} 749 750 %FIXME: multipass checking 751 %FIXME: flesh out this section 731 752 %}}} 732 753 … … 762 783 \item Can pass state around for awkward languages 763 784 \begin{itemize} 764 \item (削除) \occam~ (削除ここまで)parser uses this to track types of symbols785 \item (追記) occam (追記ここまで)parser uses this to track types of symbols 765 786 \begin{itemize} 766 787 \item e.g. "expected integer constant" … … 794 815 \begin{itemize} 795 816 \item Our frontends are nanopass-based too 796 \item For (削除) \ (削除ここまで)occam:817 \item For (追記) (追記ここまで)occam: 797 818 \begin{itemize} 798 819 \item Preprocess … … 803 824 \item Resolve grammar ambiguities 804 825 \end{itemize} 805 \end{itemize} 806 \end{frame} 807 %}}} 808 809 %{{{ usage checking 810 \section{Usage checking} 811 812 \begin{frame}[fragile] 813 \frametitle{Usage checking} 814 \begin{itemize} 815 \item Can be done using AST or CFG 816 \begin{itemize} 817 \item Latter is often easier 818 \item Use generics to label CFG nodes with variables read/written to 819 \end{itemize} 820 \end{itemize} 821 \begin{lstlisting} 822 type UsedVars = ([String], [String]) -- written, read 823 824 getUsedVars (Assign _ (VarList lhvs) rhs) 825 = (lhvs, map getJustVar (listify isJustVar rhs)) 826 827 getJustVar (JustVar v) = v 828 isJustVar (JustVar _) = True 829 isJustVar _ = False 830 \end{lstlisting} 831 %FIXME: "The code snippet is short, but I worry that it is not very 832 %understandable" 833 \end{frame} 834 835 \begin{frame} 836 \frametitle{Usage checking} 837 \begin{itemize} 838 \item As in other \occam~compilers, array indexing makes usage checking hard 839 \item For now, this problem has been skipped 840 \end{itemize} 841 \end{frame} 842 843 %FIXME: multipass checking 844 %FIXME: flesh out this section -- could merge into CFG bit? 826 \item Can use QuickCheck to generate test code 827 \end{itemize} 828 \end{frame} 845 829 %}}} 846 830 … … 864 848 \frametitle{Generating code} 865 849 \begin{itemize} 866 \item Generate (削除) code that looks like a human wrote it %FIXME: rewor (削除ここまで)d850 \item Generate (追記) idiomatic code -- as a human woul (追記ここまで)d 867 851 \begin{itemize} 868 852 \item That's what compilers are designed to handle … … 924 908 } 925 909 926 testgenWhile = (assertEqual "testgenWhile") "while(@@@)$$$" 927 (runCodeGen (genWhileC whileOps undefined undefined)) 910 testgenWhile 911 = assertEqual "testgenWhile" 912 "while(@@@)$$$" 913 (runCodeGen (genWhileC whileOps undefined undefined)) 928 914 where 929 915 whileOps = GenOps { genExpression = (\_ _ -> tell ["@@@"]), 930 916 genStatement = (\_ _ -> tell ["$$$"]) } 931 917 \end{lstlisting} 932 %FIXME: undefined saves needing to construct a value, and makes sure 933 %it's not evaluated 918 Using \lstinline|undefined| saves needed to construct a value, \\ 919 and makes sure it's not evaluated! 934 920 \end{frame} 935 921 … … 961 947 \begin{itemize} 962 948 \item Recursion, alloca, exceptions, virtual functions\ldots 963 \item But we can be careful not to generate these (for C)! 964 %Note: we can't avoid exceptions or virtual functions in C++, 965 %because they are part of C++CSP itself! 966 %FIXME: That's OK -- we don't need to analyse C++CSP itself, 967 %just like we don't analyse CCSP... say "control how we 968 %generate"? 949 \item But we can control when we generate these (or 950 avoid them entirely) 969 951 \end{itemize} 970 952 \end{itemize} … … 973 955 974 956 %{{{ language features 975 \section{ (削除) L (削除ここまで)anguage features}957 \section{(追記) occam l (追記ここまで)anguage features} 976 958 977 959 \occamsettings 978 960 961 (追記) \begin{frame} (追記ここまで) 962 (追記) \frametitle{What makes occam interesting to compile} (追記ここまで) 963 (追記) \begin{itemize} (追記ここまで) 964 (追記) \item Parallelism! (追記ここまで) 965 (追記) \item Indentation-based syntax (追記ここまで) 966 (追記) \item Parser needs lots of lookahead (追記ここまで) 967 (追記) \item Compile-time usage checks (追記ここまで) 968 (追記) \begin{itemize} (追記ここまで) 969 (追記) \item Parallel safety (追記ここまで) 970 (追記) \item Definedness (追記ここまで) 971 (追記) \end{itemize} (追記ここまで) 972 (追記) \item Abbreviations (追記ここまで) 973 (追記) \end{itemize} (追記ここまで) 974 (追記) \end{frame} (追記ここまで) 975 (追記) (追記ここまで) 976 (追記) \begin{frame} (追記ここまで) 977 (追記) \frametitle{Runtime checks} (追記ここまで) 978 (追記) \begin{itemize} (追記ここまで) 979 (追記) \item Various things are checked at runtime in occam (追記ここまで) 980 (追記) \begin{itemize} (追記ここまで) 981 (追記) \item Over/underflow on arithmetic operations (追記ここまで) 982 (追記) \item Array bounds (追記ここまで) 983 (追記) \item Data type conversions (e.g. INT32 $\rightarrow$ INT16) (追記ここまで) 984 (追記) \end{itemize} (追記ここまで) 985 (追記) \item Can compile out these checks when statically proven safe (追記ここまで) 986 (追記) \end{itemize} (追記ここまで) 987 (追記) \end{frame} (追記ここまで) 988 (追記) (追記ここまで) 979 989 \begin{frame}[fragile] 980 990 \frametitle{Abbreviations} 981 991 \begin{itemize} 982 \item (削除) \occam~ (削除ここまで)doesn't have pointers992 \item (追記) occam (追記ここまで)doesn't have pointers 983 993 \item Instead, it has a very powerful reference (``abbreviation'') system 984 994 \end{itemize} … … 998 1008 \frametitle{Array abbreviations} 999 1009 \begin{itemize} 1000 \item (削除) \ (削除ここまで)occam's arrays have some interesting features1010 \item (追記) (追記ここまで)occam's arrays have some interesting features 1001 1011 \begin{itemize} 1002 1012 \item slicing … … 1033 1043 \begin{itemize} 1034 1044 \item Can't just use the STL vector class -- no slicing! 1035 \item Wrote our own class to provide the \occam~array semantics 1036 \end{itemize} 1037 \end{itemize} 1038 \end{frame} 1039 1040 \begin{frame} 1041 \frametitle{Runtime checks} 1042 \begin{itemize} 1043 \item Various things are checked at runtime in \occampi 1044 \begin{itemize} 1045 \item Over/underflow on arithmetic operations 1046 \item Array bounds 1047 \item Data type conversions (e.g. INT32 $\rightarrow$ INT16) 1048 \end{itemize} 1049 \item Can compile out these checks when statically proven safe 1045 \item Wrote our own class to provide the occam array semantics 1046 \end{itemize} 1050 1047 \end{itemize} 1051 1048 \end{frame} … … 1064 1061 \item Straightforward for C or C++\ldots 1065 1062 \end{itemize} 1063 (追記) \item Arrays can be reshaped (追記ここまで) 1064 (追記) \end{itemize} (追記ここまで) 1065 (追記) \begin{lstlisting} (追記ここまで) 1066 (追記) [4][3]INT xs: (追記ここまで) 1067 (追記) [2][6]INT ys RESHAPES xs: (追記ここまで) 1068 (追記) \end{lstlisting} (追記ここまで) 1069 (追記) \begin{itemize} (追記ここまで) 1066 1070 \item Channels can also be retyped 1067 1071 \begin{itemize} … … 1069 1073 \item Can't use templated channels\ldots 1070 1074 \end{itemize} 1071 \item Arrays can be reshaped! 1072 \end{itemize} 1073 \begin{lstlisting} 1074 [4][3]INT xs: 1075 [2][6]INT ys RESHAPES xs: 1076 \end{lstlisting} 1075 \end{itemize} 1077 1076 \end{frame} 1078 1077 … … 1100 1099 \section{Reflections} 1101 1100 1102 \begin{frame} 1103 \frametitle{How we use Haskell} 1104 \framesubtitle{How're you gonna get your day's work done?} 1101 \subsection{How we use Haskell} 1102 1103 \begin{frame} 1104 \frametitle{How're you gonna get your day's work done?} 1105 1105 % OK, nobody is going to get the reference... 1106 1106 \begin{itemize} … … 1117 1117 1118 1118 \begin{frame}[fragile] 1119 \frametitle{How we use Haskell} 1120 \framesubtitle{Monads in disguise} 1119 \frametitle{Monads in disguise} 1121 1120 \begin{itemize} 1122 1121 \item Tock is a \emph{practical} system, therefore\ldots … … 1132 1131 1133 1132 \begin{frame} 1134 \frametitle{How we use Haskell} 1135 \framesubtitle{A fistful of dollars} 1133 \frametitle{A fistful of dollars} 1136 1134 \begin{itemize} 1137 1135 \item Use the \lstinline|$| operator to avoid nested brackets … … 1143 1141 \begin{itemize} 1144 1142 \item e.g. applying a pure function to the result of a monadic 1145 operation 1146 \end{itemize} 1147 %FIXME: find the definition of this (and the "nice" way of doing it) 1143 operation \\ 1144 \lstinline|(>>*) op f = (liftM f) op| \\ 1145 \lstinline|v <- getFoo >>* fromMaybe| 1146 \end{itemize} 1148 1147 \end{itemize} 1149 1148 \end{frame} … … 1151 1150 %FIXME: slide on the GHC extensions we use? 1152 1151 1153 \begin{frame} 1154 \frametitle{Haskell frustrations} 1155 \framesubtitle{Why doesn't this work?} 1156 \begin{itemize} 1157 \item Debugging is hard 1158 \begin{itemize} 1159 \item Tracing does not generally do what you expect (owing to laziness) 1160 \item Existing tools often have limitations that make them unworkable with Tock code 1161 \begin{itemize} 1162 \item e.g. no GHC extensions, no higher-order types, \ldots 1163 \end{itemize} 1164 \item Unit tests do help to narrow down problems 1165 \item We often resort to printf debugging (that's why 1166 \lstinline|IO| is in \lstinline|PassM|) 1167 \end{itemize} 1152 \subsection{Haskell frustrations} 1153 1154 \begin{frame} 1155 \frametitle{Debugging is hard} 1156 \begin{itemize} 1157 \item Tracing does not generally do what you expect (owing to laziness) 1158 \item Existing tools often have limitations that make them unworkable with Tock code 1159 \begin{itemize} 1160 \item e.g. no GHC extensions, no higher-order types, \ldots 1161 \end{itemize} 1162 \item Unit tests do help to narrow down problems 1163 \item We often resort to printf debugging (that's why 1164 \lstinline|IO| is in \lstinline|PassM|) 1168 1165 \end{itemize} 1169 1166 %FIXME: example of a nasty type error with solution? … … 1171 1168 1172 1169 \begin{frame} 1173 \frametitle{Haskell frustrations} 1174 \framesubtitle{What's the problem?} 1175 \begin{itemize} 1176 \item Type errors 1177 \begin{itemize} 1178 \item GHC's errors are usually enormous and hard to understand 1179 \begin{itemize} 1180 \item The line number is usually the most useful bit! 1181 \end{itemize} 1182 \item Sometimes GHC can infer the right type, but a human can't 1183 \begin{itemize} 1184 \item Would be nice to be able to ask GHCI about 1185 definitions in \lstinline|where| clauses\ldots 1186 \end{itemize} 1187 \item We often resort to trial and error 1188 \end{itemize} 1189 \end{itemize} 1190 \end{frame} 1191 1192 \begin{frame} 1193 \frametitle{Haskell frustrations} 1194 \framesubtitle{Going in circles} 1170 \frametitle{Deciphering type errors} 1171 \begin{itemize} 1172 \item GHC's errors are usually enormous and hard to understand 1173 \begin{itemize} 1174 \item The line number is usually the most useful bit! 1175 \end{itemize} 1176 \item Sometimes GHC can infer the right type, but a human can't 1177 \begin{itemize} 1178 \item Would be nice to be able to ask GHCI about 1179 definitions in \lstinline|where| clauses\ldots 1180 \end{itemize} 1181 \item We often resort to trial and error 1182 \end{itemize} 1183 \end{frame} 1184 1185 \begin{frame} 1186 \frametitle{Going in circles} 1195 1187 \begin{itemize} 1196 1188 \item Haskell disallows mutually recursive modules … … 1208 1200 1209 1201 \begin{frame} 1210 \frametitle{Haskell frustrations} 1211 \framesubtitle{A pain in the monads} 1202 \frametitle{A pain in the monads} 1212 1203 \begin{itemize} 1213 1204 \item Monad transformers aren't available for all monads … … 1222 1213 1223 1214 \begin{frame} 1224 \frametitle{ (削除) Generics API frustrations (削除ここまで)}1225 \begin{itemize} (削除) (削除ここまで)1226 \item Bad (削除) Constr (削除ここまで)equality1215 \frametitle{(追記) Not as generic as we'd like (追記ここまで)} 1216 \begin{itemize}(追記) (追記ここまで) 1217 \item Bad (追記) \lstinline|Constr| (追記ここまで) equality 1227 1218 \begin{itemize} 1228 1219 \item \lstinline$toConstr False == toConstr Nothing$ 1229 1220 \end{itemize} 1230 \item No easy way to discover number of parameters for a Constr 1221 \item No easy way to discover number of parameters for a 1222 \lstinline|Constr| 1231 1223 \begin{itemize} 1232 1224 \item Have to map ``\lstinline$const undefined$'' over the sub-terms
Note:
See TracChangeset
for help on using the changeset viewer.