Context Navigation


Changeset 29


Ignore:
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
    1111\usepackage{pifont}
    1212\usepackage{xspace}
    13(削除) \def\occam{{occam\xspace}} (削除ここまで)
    14(削除) \def\occampi{{occam-\Pisymbol{psy}{112}}\xspace} (削除ここまで)
    1513
    1614\mode<presentation>
    1715{
    18 \usetheme{(削除) Rochester (削除ここまで)}
    16 \usetheme{(追記) JuanLesPins (追記ここまで)}
    1917 \usecolortheme[named=KentBlue]{structure}
    2018 \setbeamercovered{transparent}
    2119}
    22(削除) (削除ここまで)
    2320
    2421\usepackage[english]{babel}
    3734
    3835\author{Neil Brown and Adam Sampson}
    39\institute(削除) [Universities of Somewhere and Elsewhere] % (optional, but mostly needed) (削除ここまで)
    36\institute(追記) (追記ここまで)
    4037{
    4138 Computing Laboratory\\
    9996}
    10097
    101\def\(削除) occam (削除ここまで)settings{
    98\def\(追記) rain (追記ここまで)settings{
    10299\lstset{
    103 language={(削除) [21]occam (削除ここまで)},
    100 language={(追記) c (追記ここまで)},
    104101 columns=fixed,
    105102 basicstyle=\small\ttfamily,
    103(追記) emphstyle=\color{KentBlue}\bfseries, (追記ここまで)
    106104 keywordstyle=\color{KentBlue}\bfseries,
    107105 identifierstyle=,
    111109}
    112110
    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(追記) (追記ここまで)
    113124\begin{document}
    114125
    153164 \item In 2007, it was becoming increasingly clear that we needed
    154165 a new occam compiler\ldots
    155 \item Adam wrote the initial (削除) \ (削除ここまで)occam-to-C Tock
    166 \item Adam wrote the initial (追記) (追記ここまで)occam-to-C Tock
    156167 \begin{itemize}
    157168 \item Based on FCO ``spike solution'' compiler
    171182 \item Multiple frontends
    172183 \begin{itemize}
    173 \item occam(削除) 2.1 (soon to be \occampi) (削除ここまで)
    184 \item occam(追記) 2.1 (追記ここまで)
    174185 \item Rain
    175186 \end{itemize}
    187198\frametitle{An extensible compiler}
    188199\begin{itemize}
    189 \item (削除) \occampi (削除ここまで) is very much still under development
    200 \item (追記) occam (追記ここまで) is very much still under development
    190201 \item We want to experiment with new language and runtime
    191202 features
    194205 \item Our students know Haskell (in theory)
    195206 \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 (削除ここまで)
    211207\end{itemize}
    212208\end{frame}
    317313\end{frame}
    318314
    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}
    322319\begin{itemize}
    323320 \item \lstinline|everywhere| really does look \emph{everywhere}
    338335
    339336\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}
    342338\begin{itemize}
    343339 \item Sometimes \lstinline|everywhere| is not the traversal we want
    345341 \item e.g. we only want the outermost part of a
    346342 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)|
    349344 \end{itemize}
    350345 \item No problem
    357352
    358353\begin{frame}[fragile]
    359\frametitle{Problems with generics}
    360\framesubtitle{Well, \emph{nearly} any type\ldots}
    354\frametitle{Well, \emph{nearly} any type\ldots}
    361355\begin{itemize}
    362356 \item \lstinline|Data.Generics| has some limitations
    376370\section{Testing}
    377371
    378\begin{frame}
    379\frametitle{Testing frameworks}
    372\subsection{Testing frameworks}
    373
    374\begin{frame}
    375\frametitle{The frameworks we use}
    380376\begin{itemize}
    381377 \item HUnit
    396392
    397393\begin{frame}[fragile]
    398\frametitle{(削除) Testing Frameworks Example (削除ここまで)s}
    394\frametitle{(追記) Some example test (追記ここまで)s}
    399395\begin{lstlisting}
    400396-- HUnit example:
    401(assertEqual "Test 0") "foo_bar" (cStyleNames "foo.bar")
    397assertEqual "Test 0"
    398 "foo_bar"
    399 (cStyleNames "foo.bar")
    402400
    403401-- QuickCheck example:
    409407 = check (execRandom (seed n) (randList (n/10)))
    410408 where
    411 check ns = (all ((削除) \x -> x (削除ここまで)> 0) ns) && (sum ns == n)
    409 check ns = (all ((追記) (追記ここまで)> 0) ns) && (sum ns == n)
    412410\end{lstlisting}
    413411\end{frame}
    414412%TODO consider replacing the above QuickCheck example with a simpler one
    415413
    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}
    436415
    437416\begin{frame}[fragile]
    438417\frametitle{Ignoring elements}
    439\begin{verbatim}
    418Some 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}
    440424if (a) { }
    441\end{verbatim}
    425\end{lstlisting}
    426
    427parses as:
    428\haskellsettings
    429\lstset{emph={Pos}}
    442430\begin{lstlisting}
    443431If
    444432 (Pos 0)
    445433 (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={}}
    449437\end{frame}
    450438
    451439\begin{frame}[fragile]
    452440\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) { }"))
    441Could match the output exactly:
    442\begin{lstlisting}
    443assertEqual "If Test 0"
    444 (If (Pos 0) (Expr (Pos 4) (JustVar "a")) (Block (Pos 7) []))
    445 (parse "if (a) { }")
    446\end{lstlisting}
    447
    448But it's more robust to use a pattern match:
    449\begin{lstlisting}
    450assertBool "If Test 0" (checkIfTest0 (parse "if (a) { }"))
    459451 where
    460452 checkIfTest0
    461453 (If _
    462454 (Expr _ (JustVar "a"))
    463 (Block _ [(削除) (削除ここまで)])
    455 (Block _ [(追記) (追記ここまで)])
    464456 ) = True
    465457 checkIfTest0 _ = False
    468460
    469461\begin{frame}[fragile]
    470\frametitle{Matching elements}
    462\frametitle{Avoiding duplicate code}
    463
    464Testing that a pass generates the correct code to swap two variables:
    471465\occamsettings
    472466\begin{lstlisting}
    473x, y := y, x
    474
    475t := y
    467temp42 := y
    476468y := x
    477x := t
    478\end{lstlisting}
    469x := temp42
    470\end{lstlisting}
    471
    472This has to be matched as:
    479473\haskellsettings
    480474\begin{lstlisting}
    481Assign p0 (VarList p0 ["x", "y"]) (ExprList p0 [JustVar "x", JustVar "y"])
    482
    483Block 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"])
    475Block
    476 [ Assign (VarList ["temp42"]) (ExprList [JustVar "y"])
    477 , Assign (VarList ["y"]) (ExprList [JustVar "x"])
    478 , Assign (VarList ["x"]) (ExprList [JustVar "temp42"])
    487479 ]
    488
    489p0 = 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}
    485We can remove some of the duplication using a helper function:
    486
    487\begin{lstlisting}
    488assertEqual "tempAssignTest 0"
    489 (Block
    490 [ singleAssign "temp42" "y"
    500491 , singleAssign "y" "x"
    501 , singleAssign "x" "t(削除) (削除ここまで)"
    492 , singleAssign "x" "t(追記) emp42 (追記ここまで)"
    502493 ])
    503494 testOutput
    504495
    505496singleAssign 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
    500But 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}
    505We don't care what the temporary variable is called -- just that it's
    506the same one that's used in both cases:
    507
    514508\begin{lstlisting}
    515509assertBool "tempAssignTest 0"
    516510 (checktempAssignTest0 testOutput)
    517511
    518checktempAssignTest0 (Block(削除) _ (削除ここまで)
    519 [ Assign (削除) _ (VarList _ [tempVar0]) (ExprList _ (削除ここまで) [JustVar "y"])
    520 , Assign (削除) _ (VarList _ ["y"]) (ExprList _ (削除ここまで) [JustVar "x"])
    521 , Assign (削除) _ (VarList _ ["x"]) (ExprList _ (削除ここまで) [JustVar tempVar1])
    512checktempAssignTest0 (Block(追記) (追記ここまで)
    513 [ Assign (追記) (VarList [tempVar0]) (ExprList (追記ここまで) [JustVar "y"])
    514 , Assign (追記) (VarList ["y"]) (ExprList (追記ここまで) [JustVar "x"])
    515 , Assign (追記) (VarList ["x"]) (ExprList (追記ここまで) [JustVar tempVar1])
    522516 ])
    523517 = tempVar0 == tempVar1
    524518checktempAssignTest0 _ = False
    525519\end{lstlisting}
    520(追記) (追記ここまで)
    521(追記) But now we can't use our helper function any more. (追記ここまで)
    526522\end{frame}
    527523
    540536 \item But this isn't implemented yet\ldots
    541537 \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 (削除ここまで)
    549538 \item Parser combinators?
    550539 \begin{itemize}
    551540 \item Would work, but the syntax is awful
    552541 \end{itemize}
    553(削除) \item Generics (削除ここまで)
    554542\end{itemize}
    555543\end{frame}
    557545\begin{frame}[fragile]
    558546\frametitle{Generic pattern-matching}
    559\begin{itemize}
    560 \item Built on \lstinline|Data.Generics|
    561\end{itemize}
    547Built our own pattern-matching library using \lstinline|Data.Generics|
    562548\begin{lstlisting}
    563549type Pattern =
    564 D(削除) C (削除ここまで)
    550 D(追記) on'tCare (追記ここまで)
    565551 | Named String Pattern
    566552 | Match Constr [Pattern]
    567553\end{lstlisting}
    568\begin{itemize}
    569\item All \lstinline|Named| items with the same name must match
    554All \lstinline|Named| items with the same name must match
    570555\end{itemize}
    571556\end{frame}
    588573 (Pos 0)
    589574 (Expr (Pos 4) (JustVar "a"))
    590 (Block (Pos 7) [(削除) (削除ここまで)]))
    575 (Block (Pos 7) [(追記) (追記ここまで)]))
    591576
    592577assertPatternMatch "If Test 0"
    593578 (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])))
    597582 (parse "if (a) { }")
    598583
    606591\frametitle{Generic pattern matching}
    607592\begin{lstlisting}
    608(assertPatternMatch "tempAssignTest 0")
    609 (mBlock D(削除) C (削除ここまで)
    610 [ singleAssign' ("tempVar" @@ D(削除) C (削除ここまで)) "y"
    593assertPatternMatch "tempAssignTest 0"
    594 (mBlock D(追記) on'tCare (追記ここまで)
    595 [ singleAssign' ("tempVar" @@ D(追記) on'tCare (追記ここまで)) "y"
    611596 , singleAssign' "y" "x"
    612 , singleAssign' "x" ("tempVar" @@ D(削除) C (削除ここまで))
    597 , singleAssign' "x" ("tempVar" @@ D(追記) on'tCare (追記ここまで))
    613598 ])
    614599 testOutput
    615600
    616singleAssign' lhv rhv = mAssign D(削除) C (削除ここまで)
    617 (mVarList D(削除) C (削除ここまで) [lhv])
    618 (mExprList D(削除) C (削除ここまで) [mJustVar rhv])
    601singleAssign' lhv rhv = mAssign D(追記) on'tCare (追記ここまで)
    602 (mVarList D(追記) on'tCare (追記ここまで) [lhv])
    603 (mExprList D(追記) on'tCare (追記ここまで) [mJustVar rhv])
    619604\end{lstlisting}
    620605%FIXME: Point out that singleAssign' can be reused between tests
    630615 \item Functions are trickier
    631616 \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 (追記ここまで)
    633618 \item Speed's not great
    634619 \begin{itemize}
    641626%}}}
    642627
    643%{{{ control flow graphs
    644\section{Control-flow graphs}
    628%{{{ code analysis
    629\section{Code analysis}
    630
    631\subsection{Tree navigation}
    645632
    646633\begin{frame}
    647634\frametitle{Control-flow graphs}
    648635\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
    651644 \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?
    653654 \begin{itemize}
    654655 \item No unique identifiers in AST
    655656 \item Only unique thing is the position in the tree
    656657 \item No easy way to find \emph{and modify} a particular spot
    657 in a tree(削除) (using monadic modifications, too!) (削除ここまで)
    658 in a tree(追記) (追記ここまで)
    658659 \end{itemize}
    659660\end{itemize}
    662663\begin{frame}
    663664\frametitle{Navigating the AST}
    664(削除) %FIXME: picture (削除ここまで)
    665665\begin{columns}
    666666\column{.5\textwidth}
    718718\end{frame}
    719719
    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}
    729type UsedVars = ([String], [String]) -- written, read
    730
    731getUsedVars (Assign _ (VarList lhvs) rhs)
    732 = (lhvs, map getJustVar (listify isJustVar rhs))
    733
    734getJustVar (JustVar v) = v
    735isJustVar (JustVar _) = True
    736isJustVar _ = 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
    731752%}}}
    732753
    762783 \item Can pass state around for awkward languages
    763784 \begin{itemize}
    764 \item (削除) \occam~ (削除ここまで)parser uses this to track types of symbols
    785 \item (追記) occam (追記ここまで)parser uses this to track types of symbols
    765786 \begin{itemize}
    766787 \item e.g. "expected integer constant"
    794815\begin{itemize}
    795816 \item Our frontends are nanopass-based too
    796 \item For (削除) \ (削除ここまで)occam:
    817 \item For (追記) (追記ここまで)occam:
    797818 \begin{itemize}
    798819 \item Preprocess
    803824 \item Resolve grammar ambiguities
    804825 \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}
    822type UsedVars = ([String], [String]) -- written, read
    823
    824getUsedVars (Assign _ (VarList lhvs) rhs)
    825 = (lhvs, map getJustVar (listify isJustVar rhs))
    826
    827getJustVar (JustVar v) = v
    828isJustVar (JustVar _) = True
    829isJustVar _ = 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}
    845829%}}}
    846830
    864848\frametitle{Generating code}
    865849\begin{itemize}
    866 \item Generate (削除) code that looks like a human wrote it %FIXME: rewor (削除ここまで)d
    850 \item Generate (追記) idiomatic code -- as a human woul (追記ここまで)d
    867851 \begin{itemize}
    868852 \item That's what compilers are designed to handle
    924908}
    925909
    926testgenWhile = (assertEqual "testgenWhile") "while(@@@)$$$"
    927 (runCodeGen (genWhileC whileOps undefined undefined))
    910testgenWhile
    911 = assertEqual "testgenWhile"
    912 "while(@@@)$$$"
    913 (runCodeGen (genWhileC whileOps undefined undefined))
    928914 where
    929915 whileOps = GenOps { genExpression = (\_ _ -> tell ["@@@"]),
    930916 genStatement = (\_ _ -> tell ["$$$"]) }
    931917\end{lstlisting}
    932%FIXME: undefined saves needing to construct a value, and makes sure
    933%it's not evaluated
    918Using \lstinline|undefined| saves needed to construct a value, \\
    919and makes sure it's not evaluated!
    934920\end{frame}
    935921
    961947 \begin{itemize}
    962948 \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)
    969951 \end{itemize}
    970952\end{itemize}
    973955
    974956%{{{ language features
    975\section{(削除) L (削除ここまで)anguage features}
    957\section{(追記) occam l (追記ここまで)anguage features}
    976958
    977959\occamsettings
    978960
    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(追記) (追記ここまで)
    979989\begin{frame}[fragile]
    980990\frametitle{Abbreviations}
    981991\begin{itemize}
    982 \item (削除) \occam~ (削除ここまで)doesn't have pointers
    992 \item (追記) occam (追記ここまで)doesn't have pointers
    983993 \item Instead, it has a very powerful reference (``abbreviation'') system
    984994\end{itemize}
    9981008\frametitle{Array abbreviations}
    9991009\begin{itemize}
    1000 \item (削除) \ (削除ここまで)occam's arrays have some interesting features
    1010 \item (追記) (追記ここまで)occam's arrays have some interesting features
    10011011 \begin{itemize}
    10021012 \item slicing
    10331043 \begin{itemize}
    10341044 \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}
    10501047\end{itemize}
    10511048\end{frame}
    10641061 \item Straightforward for C or C++\ldots
    10651062 \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} (追記ここまで)
    10661070 \item Channels can also be retyped
    10671071 \begin{itemize}
    10691073 \item Can't use templated channels\ldots
    10701074 \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}
    10771076\end{frame}
    10781077
    11001099\section{Reflections}
    11011100
    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?}
    11051105% OK, nobody is going to get the reference...
    11061106\begin{itemize}
    11171117
    11181118\begin{frame}[fragile]
    1119\frametitle{How we use Haskell}
    1120\framesubtitle{Monads in disguise}
    1119\frametitle{Monads in disguise}
    11211120\begin{itemize}
    11221121 \item Tock is a \emph{practical} system, therefore\ldots
    11321131
    11331132\begin{frame}
    1134\frametitle{How we use Haskell}
    1135\framesubtitle{A fistful of dollars}
    1133\frametitle{A fistful of dollars}
    11361134\begin{itemize}
    11371135 \item Use the \lstinline|$| operator to avoid nested brackets
    11431141 \begin{itemize}
    11441142 \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}
    11481147\end{itemize}
    11491148\end{frame}
    11511150%FIXME: slide on the GHC extensions we use?
    11521151
    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|)
    11681165\end{itemize}
    11691166%FIXME: example of a nasty type error with solution?
    11711168
    11721169\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}
    11951187\begin{itemize}
    11961188 \item Haskell disallows mutually recursive modules
    12081200
    12091201\begin{frame}
    1210\frametitle{Haskell frustrations}
    1211\framesubtitle{A pain in the monads}
    1202\frametitle{A pain in the monads}
    12121203\begin{itemize}
    12131204 \item Monad transformers aren't available for all monads
    12221213
    12231214\begin{frame}
    1224\frametitle{(削除) Generics API frustrations (削除ここまで)}
    1225\begin{itemize}(削除) (削除ここまで)
    1226 \item Bad (削除) Constr (削除ここまで) equality
    1215\frametitle{(追記) Not as generic as we'd like (追記ここまで)}
    1216\begin{itemize}(追記) (追記ここまで)
    1217 \item Bad (追記) \lstinline|Constr| (追記ここまで) equality
    12271218 \begin{itemize}
    12281219 \item \lstinline$toConstr False == toConstr Nothing$
    12291220 \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|
    12311223 \begin{itemize}
    12321224 \item Have to map ``\lstinline$const undefined$'' over the sub-terms
Note: See TracChangeset for help on using the changeset viewer.

AltStyle によって変換されたページ (->オリジナル) /