Context Navigation


Changeset 208


Ignore:
Timestamp:
Feb 7, 2008, 6:28:15 PM (18 years ago)
Author:
neil.c.c.brown
Message:

Fixed the tock introduction to reflect Structured becoming parameterised.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/trunk/hacking-guide/tock-intro.tex

    r198 r208
    9494\subsection{A.Structured}
    9595
    96The main item in the AST that I (Neil) found confusing at first was the Structured item. In case it
    97confuses anyone else I thought I would explain it here. Structured is the body of most occam constructs,
    96The main item in the AST that I (Neil) found confusing at first was the Structured item.
    97Thankfully, I've recently changed Structured to be parameterised, but I've left this explanation
    98in anyway, it case it helps. Structured is the body of most occam constructs,
    9899such as SEQ, PAR, ALT, CASE. Because occam allows the inter-mingling of processes and declarations,
    99100and also replication on most of its constructs (SEQ, PAR, ALT, IF) Structured eliminates redundancy
    100by grouping this together. So for example, given this occam pseudo-code:
    101by grouping this together. SEQ and PAR have a \lstinline|A.Structured A.Process| as their `body',
    102whereas, for example, ALT has a \lstinline|A.Structured A.Alternative|.
    103So for example, given this occam pseudo-code:
    101104
    102105\occamsettings\begin{lstlisting}
    112115A.Seq m
    113116 (A.Several m
    114 [A.Only(削除) P (削除ここまで) m proc1
    115 ,A.Only(削除) P (削除ここまで) m proc2
    117 [A.Only(追記) (追記ここまで) m proc1
    118 ,A.Only(追記) (追記ここまで) m proc2
    116119 ]
    117120 )
    118121\end{lstlisting}
    119122
    120You can see the combination of Seq with Several and Only(削除) P (削除ここまで) to nest the processes. Here's another example
    123You can see the combination of Seq with Several and Only(追記) (追記ここまで) to nest the processes. Here's another example
    121124of some occam and corresponding Haskell:
    122125
    132135A.Seq m
    133136 (A.Several m
    134 [A.Only(削除) P (削除ここまで) m proc1
    135 ,A.Only(削除) P (削除ここまで) m
    137 [A.Only(追記) (追記ここまで) m proc1
    138 ,A.Only(追記) (追記ここまで) m
    136139 (A.Par m A.PlainPar
    137140 (A.Several m
    138 [A.Only(削除) P (削除ここまで) m proc2
    139 ,A.Only(削除) P (削除ここまで) m proc3
    141 [A.Only(追記) (追記ここまで) m proc2
    142 ,A.Only(追記) (追記ここまで) m proc3
    140143 ]
    141144 )
    159162A.Seq m
    160163 (A.Several m
    161 [A.Only(削除) P (削除ここまで) m proc1
    164 [A.Only(追記) (追記ここまで) m proc1
    162165 , (A.Several m
    163 [A.Only(削除) P (削除ここまで) m proc2
    164 ,A.Only(削除) P (削除ここまで) m proc3
    166 [A.Only(追記) (追記ここまで) m proc2
    167 ,A.Only(追記) (追記ここまで) m proc3
    165168 ]
    166169 )
    185188A.Par m A.PlainPar
    186189 (A.Several m
    187 [A.Only(削除) P (削除ここまで) m proc1
    188 ,A.Rep m rep (A.Only(削除) P (削除ここまで) m proc2)
    190 [A.Only(追記) (追記ここまで) m proc1
    191 ,A.Rep m rep (A.Only(追記) (追記ここまで) m proc2)
    189192 ]
    190193 )
    208211A.Seq m
    209212 (A.Several m
    210 [A.Only(削除) P (削除ここまで) m proc1
    211 ,A.Specification m spec (A.Only(削除) P (削除ここまで) m proc2)
    213 [A.Only(追記) (追記ここまで) m proc1
    214 ,A.Specification m spec (A.Only(追記) (追記ここまで) m proc2)
    212215 ]
    213216 )
    229232A.Seq m
    230233 (A.Several m
    231 [A.Only(削除) P (削除ここまで) m proc1
    234 [A.Only(追記) (追記ここまで) m proc1
    232235 ,A.Specification m specX
    233 (A.Specification m specY (A.Only(削除) P (削除ここまで) m proc2))
    236 (A.Specification m specY (A.Only(追記) (追記ここまで) m proc2))
    234237 ]
    235238 )
    236239\end{lstlisting}
    237(削除) (削除ここまで)
    238(削除) Note that each of the actual items in a Structured is named OnlyP (Process), OnlyA (ALT guard), etc. (削除ここまで)
    239(削除) To be valid, any SEQ must contain no Only* items except OnlyP. Similarly, an ALT must contain (削除ここまで)
    240(削除) no Only* items except OnlyA, and so on. (削除ここまで)
    241240
    242241\subsection{Monadic Code}
    283282 | (v, v') <- zip vs temps]
    284283 return $ A.Seq m $ foldl (\s spec -> A.Spec m spec s)
    285 (A.Several m (map (A.Only(削除) P (削除ここまで) m) (first ++ second))) specs
    284 (A.Several m (map (A.Only(追記) (追記ここまで) m) (first ++ second))) specs
    286285doProcess p = doGeneric p
    287286\end{lstlisting}
Note: See TracChangeset for help on using the changeset viewer.

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