- Timestamp:
- Mar 23, 2017, 11:30:42 AM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 578b637
- Parents:
- 9fcdfa3 (diff), 27cc24e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- doc
- Files:
-
- 1 added
- 2 edited
-
generic_types/generic_types.tex (modified) (2 diffs)
-
rob_thesis/Makefile (added)
-
user/user.tex (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/generic_types/generic_types.tex
r9fcdfa3 rc58f4ab 139 139 \begin{lstlisting} 140 140 forall(otype T) 141 T identity(T x) { is_141 T identity(T x) { 142 142 return x; 143 143 } … … 294 294 Since @pair(T*, T*)@ is a concrete type, there are no added implicit parameters to @lexcmp@, so the code generated by \CFA{} will be effectively identical to a version of this written in standard C using @void*@, yet the \CFA{} version will be type-checked to ensure that the fields of both pairs and the arguments to the comparison function match in type. 295 295 296 \TODO{} The second is zero-cost ``tag'' structs. 296 Another useful pattern enabled by re-used dtype-static type instantiations is zero-cost ``tag'' structs. Sometimes a particular bit of information is only useful for type-checking, and can be omitted at runtime. Tag structs can be used to provide this information to the compiler without further runtime overhead, as in the following example: 297 \begin{lstlisting} 298 forall(dtype Unit) struct scalar { unsigned long value; }; 299 300 struct metres {}; 301 struct litres {}; 302 303 forall(dtype U) 304 scalar(U) ?+?(scalar(U) a, scalar(U) b) { 305 return (scalar(U)){ a.value + b.value }; 306 } 307 308 scalar(metres) half_marathon = { 21093 }; 309 scalar(litres) swimming_pool = { 2500000 }; 310 311 scalar(metres) marathon = half_marathon + half_marathon; 312 scalar(litres) two_pools = swimming_pool + swimming_pool; 313 marathon + swimming_pool; // ERRORv -- caught by compiler 314 \end{lstlisting} 315 @scalar@ is a dtype-static type, so all uses of it will use a single struct definition, containing only a single @unsigned long@, and can share the same implementations of common routines like @?+?@ -- these implementations may even be separately compiled, unlike \CC{} template functions. However, the \CFA{} type-checker will ensure that matching types are used by all calls to @?+?@, preventing nonsensical computations like adding the length of a marathon to the volume of an olympic pool. 297 316 298 317 \section{Tuples} -
doc/user/user.tex
r9fcdfa3 rc58f4ab 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Mon Feb 20 12:35:48201714 %% Update Count : 13 7713 %% Last Modified On : Thu Mar 23 09:53:57 2017 14 %% Update Count : 1399 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 91 91 }% title 92 92 93 \author{\huge 94 Peter A. Buhr and ... 93 \author{ 94 \huge \CFA Team \medskip \\ 95 \Large Peter A. Buhr, Richard Bilson, Thierry Delisle, \smallskip \\ 96 \Large Glen Ditchfield, Rodolfo G. Esteves, Aaron Moss, Rob Schluntz 95 97 }% author 96 98 … … 4657 4659 which is a local mechanism to disable insertion of the separator character. 4658 4660 \item 4659 A separator does not appear before a C string starting with the (extended) \Index{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off]@([{ $£¥¡¿«@4661 A separator does not appear before a C string starting with the (extended) \Index{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off]@([{=$£¥¡¿«@ 4660 4662 %$ 4661 4663 \begin{lstlisting}[mathescape=off] 4662 sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x $" | 4 | "x £" | 5 | "x ¥" | 6 | "x ¡" | 74663 | "x ¿" | 8 | "x «" | 9| endl;4664 sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x =" | 4 | "x $" | 5 | "x £" | 6 | "x ¥" | 7 4665 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10 | endl; 4664 4666 \end{lstlisting} 4665 4667 %$ 4666 4668 \begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 4667 x (1 x [2 x {3 x $4 x £5 x ¥6 x ¡7 x ¿8 x «94669 x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10 4668 4670 \end{lstlisting} 4669 4671 %$ 4670 4672 \item 4673 {\lstset{deletedelim=**[is][]{¢}{¢}} 4671 4674 A seperator does not appear after a C string ending with the (extended) \Index{ASCII}\index{ASCII!extended} characters: ©,.:;!?)]}%¢»© 4672 4675 \begin{lstlisting}[belowskip=0pt] 4673 sout | 1 | ", x" | 2 | ". x" | 3 | ": x" | 4 | "; x" | 5 | "! x" | 6 | "? x" | 7 4674 | ") x" | 8 | "] x" | 9 | "} x" | 10 | "% x" | 11 | "¢ x" | 12 | "»x" | endl;4676 sout | 1 | ", x" | 2 | ". x" | 3 | ": x" | 4 | "; x" | 5 | "! x" | 6 | "? x" | 7 | "% x" 4677 | 8 | "¢ x" | 9 | "» x" | 10 | ") x" | 11 | "] x" | 12 | "} x" | endl; 4675 4678 \end{lstlisting} 4676 4679 \begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 4677 1, x 2. x 3: x 4; x 5! x 6? x 7 ) x 8] x 9} x 10% x 11¢ 12»4678 \end{lstlisting} 4680 1, x 2. x 3: x 4; x 5! x 6? x 7% x 8¢ x 9» x 10) x 11] x 12} x 4681 \end{lstlisting}}% 4679 4682 \item 4680 4683 A seperator does not appear before or after a C string begining/ending with the \Index{ASCII} quote or whitespace characters: \lstinline[showspaces=true]@`'" \t\v\f\r\n@ … … 4694 4697 \end{lstlisting} 4695 4698 \begin{lstlisting}[mathescape=off,aboveskip=0pt,belowskip=0pt] 4696 sout | 1 | sepOff | 2 | 3 | endl; §\C{// turn off implicit separator temporarily}§4699 sout | 1 | sepOff | 2 | 3 | endl; §\C{// turn off implicit separator locally}§ 4697 4700 \end{lstlisting} 4698 4701 \begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] … … 4700 4703 \end{lstlisting} 4701 4704 \begin{lstlisting}[mathescape=off,aboveskip=0pt,belowskip=0pt] 4702 sout | sepDisable | 1 | 2 | 3 | endl; §\C{// turn off implicit separation , affects all subsequent prints}§4705 sout | sepDisable | 1 | 2 | 3 | endl; §\C{// turn off implicit separation globally}§ 4703 4706 \end{lstlisting} 4704 4707 \begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] … … 4706 4709 \end{lstlisting} 4707 4710 \begin{lstlisting}[mathescape=off,aboveskip=0pt,belowskip=0pt] 4708 sout | 1 | sepOn | 2 | 3 | endl; §\C{// turn on implicit separator temporarily}§4711 sout | 1 | sepOn | 2 | 3 | endl; §\C{// turn on implicit separator locally}§ 4709 4712 \end{lstlisting} 4710 4713 \begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] … … 4712 4715 \end{lstlisting} 4713 4716 \begin{lstlisting}[mathescape=off,aboveskip=0pt,belowskip=0pt] 4714 sout | sepEnable | 1 | 2 | 3 | endl; §\C{// turn on implicit separation , affects all subsequent prints}§4717 sout | sepEnable | 1 | 2 | 3 | endl; §\C{// turn on implicit separation globally}§ 4715 4718 \end{lstlisting} 4716 4719 \begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] … … 4730 4733 4731 4734 int main() { 4732 int x = 3, y = 5, z = 7;4733 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl ;4735 int x = 0, y = 1, z = 2; 4736 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl | endl; 4734 4737 sout | 1 | 2 | 3 | endl; 4735 4738 sout | '1' | '2' | '3' | endl; 4736 4739 sout | 1 | "" | 2 | "" | 3 | endl; 4737 sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x $" | 4 | "x £" | 5 | "x ¥" | 6 | "x ¡" | 7 | "x ¿" | 8 | "x «" | 9 | endl; 4738 sout | 1 | ", x" | 2 | ". x" | 3 | ": x" | 4 | "; x" | 5 | "! x" | 6 | "? x" | 7 | ") x" | 8 | "] x" | 9 | "} x" 4739 | 10 | "% x" | 11 | "¢ x" | 12 | "» x" | endl; 4740 sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x =" | 4 | "x $" | 5 | "x £" | 6 | "x ¥" | 7 4741 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10 | endl; 4742 sout | 1 | ", x" | 2 | ". x" | 3 | ": x" | 4 | "; x" | 5 | "! x" | 6 | "? x" | 7 | "% x" 4743 | 8 | "¢ x" | 9 | "» x" | 10 | ") x" | 11 | "] x" | 12 | "} x" | endl; 4740 4744 sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x" | "x " | 4 | " x" | "x\t" | 1 | "\tx" | endl; 4741 4745 sout | sepOn | 1 | 2 | 3 | sepOn | endl; // separator at start of line
Note:
See TracChangeset
for help on using the changeset viewer.