Changeset 8f67d44
- Timestamp:
- Feb 13, 2018, 6:16:56 PM (7 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:
- cd310f7
- Parents:
- 9c75137
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
r9c75137 r8f67d44 4 4 \usepackage{epic,eepic} 5 5 \usepackage{xspace,calc,comment} 6 \usepackage{upquote} % switch curled `'" to straight 7 \usepackage{listings} % format program code 6 \usepackage{upquote} % switch curled `'" to straight 7 \usepackage{listings} % format program code 8 \usepackage[flushmargin]{footmisc} % support label/reference in footnote 8 9 \usepackage{rotating} 9 10 \usepackage[usenames]{color} 10 \usepackage{pslatex} % reduce size of san serif font11 \usepackage{pslatex} % reduce size of san serif font 11 12 \usepackage[plainpages=false,pdfpagelabels,pdfpagemode=UseNone,pagebackref=true,breaklinks=true,colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref} 12 13 13 14 \setlength{\textheight}{9in} 14 15 %\oddsidemargin 0.0in 15 \renewcommand{\topfraction}{0.8} % float must be greater than X of the page before it is forced onto its own page16 \renewcommand{\bottomfraction}{0.8} % float must be greater than X of the page before it is forced onto its own page17 \renewcommand{\floatpagefraction}{0.8} % float must be greater than X of the page before it is forced onto its own page18 \renewcommand{\textfraction}{0.0} % the entire page maybe devoted to floats with no text on the page at all19 20 \lefthyphenmin=4 % hyphen only after 4 characters16 \renewcommand{\topfraction}{0.8} % float must be greater than X of the page before it is forced onto its own page 17 \renewcommand{\bottomfraction}{0.8} % float must be greater than X of the page before it is forced onto its own page 18 \renewcommand{\floatpagefraction}{0.8} % float must be greater than X of the page before it is forced onto its own page 19 \renewcommand{\textfraction}{0.0} % the entire page maybe devoted to floats with no text on the page at all 20 21 \lefthyphenmin=4 % hyphen only after 4 characters 21 22 \righthyphenmin=4 22 23 … … 24 25 25 26 \newcommand{\CFAIcon}{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name 26 \newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption27 \newcommand{\CFL}{\textrm{Cforall}\xspace} % Cforall symbolic name28 \newcommand{\Celeven}{\textrm{C11}\xspace} % C11 symbolic name27 \newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption 28 \newcommand{\CFL}{\textrm{Cforall}\xspace} % Cforall symbolic name 29 \newcommand{\Celeven}{\textrm{C11}\xspace} % C11 symbolic name 29 30 \newcommand{\CC}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name 30 31 \newcommand{\CCeleven}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name … … 56 57 \newcommand{\LstCommentStyle}[1]{{\lst@basicstyle{\lst@commentstyle{#1}}}} 57 58 58 \newlength{\gcolumnposn} % temporary hack because lstlisting does not handle tabs correctly59 \newlength{\gcolumnposn} % temporary hack because lstlisting does not handle tabs correctly 59 60 \newlength{\columnposn} 60 61 \setlength{\gcolumnposn}{2.75in} … … 72 73 73 74 % Latin abbreviation 74 \newcommand{\abbrevFont}{\textit} % set empty for no italics75 \newcommand{\abbrevFont}{\textit} % set empty for no italics 75 76 \newcommand{\EG}{\abbrevFont{e}.\abbrevFont{g}.} 76 77 \newcommand*{\eg}{% … … 1116 1117 \CFA disallows the declaration of local variable, \eg @z@, directly within the @switch@ body, because a declaration cannot occur immediately after a @case@ since a label can only be attached to a statement, and the use of @z@ is undefined in @case 1@ as neither storage allocation nor initialization may have occurred. 1117 1118 1118 C @switch@ provides multiple entry points into the statement body, but once an entry point is selected, control continues across \emph{all} @case@ clauses until the end of the @switch@ body, called \newterm{fall through} .1119 C @switch@ provides multiple entry points into the statement body, but once an entry point is selected, control continues across \emph{all} @case@ clauses until the end of the @switch@ body, called \newterm{fall through}; 1119 1120 @case@ clauses are made disjoint by the @break@ statement. 1120 1121 While the ability to fall through \emph{is} a useful form of control flow, it does not match well with programmer intuition, resulting in many errors from missing @break@ statements. … … 1538 1539 Therefore, a programmer has the option of either continuing to use traditional C declarations or take advantage of the new style. 1539 1540 Clearly, both styles need to be supported for some time due to existing C-style header-files, particularly for UNIX-like systems. 1541 1542 The syntax of the new routine prototype declaration follows directly from the new routine definition syntax; 1543 as well, parameter names are optional, \eg: 1544 \begin{cfa} 1545 [ int x ] f (); $\C{// returning int with no parameters}$ 1546 [ * int ] g (int y); $\C{// returning pointer to int with int parameter}$ 1547 [ ] h ( int, char ); $\C{// returning no result with int and char parameters}$ 1548 [ * int, int ] j ( int ); $\C{// returning pointer to int and int, with int parameter}$ 1549 \end{cfa} 1550 This syntax allows a prototype declaration to be created by cutting and pasting source text from the routine definition header (or vice versa). 1551 Like C, it is possible to declare multiple routine-prototypes in a single declaration, where the return type is distributed across \emph{all} routine names in the declaration list, \eg: 1552 \begin{cquote} 1553 \lstDeleteShortInline@% 1554 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1555 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1556 \begin{cfa} 1557 [double] foo(), foo( int ), foo( double ) {...} 1558 \end{cfa} 1559 & 1560 \begin{cfa} 1561 double foo1(), foo2( int ), foo3( double ); 1562 \end{cfa} 1563 \end{tabular} 1564 \lstMakeShortInline@% 1565 \end{cquote} 1566 \CFA allows the last routine in the list to define its body. 1567 1568 Declaration qualifiers can only appear at the start of a \CFA routine declaration,\footref{StorageClassSpecifier} \eg: 1569 \begin{cfa} 1570 extern [ int ] f ( int ); 1571 static [ int ] g ( int ); 1572 \end{cfa} 1573 1574 The syntax for pointers to \CFA routines specifies the pointer name on the right, \eg: 1575 \begin{cfa} 1576 * [ int x ] () fp; $\C{// pointer to routine returning int with no parameters}$ 1577 * [ * int ] (int y) gp; $\C{// pointer to routine returning pointer to int with int parameter}$ 1578 * [ ] (int,char) hp; $\C{// pointer to routine returning no result with int and char parameters}$ 1579 * [ * int,int ] ( int ) jp; $\C{// pointer to routine returning pointer to int and int, with int parameter}$ 1580 \end{cfa} 1581 While parameter names are optional, \emph{a routine name cannot be specified}; 1582 for example, the following is incorrect: 1583 \begin{cfa} 1584 * [ int x ] f () fp; $\C{// routine name "f" is not allowed}$ 1585 \end{cfa} 1540 1586 1541 1587 … … 1764 1810 \end{cfa} 1765 1811 }% 1812 1813 1814 \section{Libraries} 1815 1816 \subsection{I/O} 1817 \label{s:IOLibrary} 1818 1819 The goal of \CFA I/O is to simplify the common cases, while fully supporting polymorphism and user defined types in a consistent way. 1820 The approach combines ideas from \CC and Python. 1821 The \CFA header file for the I/O library is @fstream@. 1822 1823 The common case is printing out a sequence of variables separated by whitespace. 1824 \begin{cquote} 1825 \lstDeleteShortInline@% 1826 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1827 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{\CC}} \\ 1828 \begin{cfa} 1829 int x = 1, y = 2, z = 3; 1830 sout | x `|` y `|` z | endl; 1831 \end{cfa} 1832 & 1833 \begin{cfa} 1834 1835 cout << x `<< " "` << y `<< " "` << z << endl; 1836 \end{cfa} 1837 \\ 1838 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 1839 1` `2` `3 1840 \end{cfa} 1841 & 1842 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 1843 1 2 3 1844 \end{cfa} 1845 \end{tabular} 1846 \lstMakeShortInline@% 1847 \end{cquote} 1848 The \CFA form has half the characters of the \CC form, and is similar to Python I/O with respect to implicit separators. 1849 Similar simplification occurs for tuple I/O, which prints all tuple values separated by ``\lstinline[showspaces=true]@, @''. 1850 \begin{cfa} 1851 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ]; 1852 sout | t1 | t2 | endl; $\C{// print tuples}$ 1853 \end{cfa} 1854 \begin{cfa}[showspaces=true,aboveskip=0pt] 1855 1`, `2`, `3 4`, `5`, `6 1856 \end{cfa} 1857 Finally, \CFA uses the logical-or operator for I/O as it is the lowest-priority overloadable operator, other than assignment. 1858 Therefore, fewer output expressions require parenthesis. 1859 \begin{cquote} 1860 \lstDeleteShortInline@% 1861 \begin{tabular}{@{}ll@{}} 1862 \textbf{\CFA:} 1863 & 1864 \begin{cfa} 1865 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl; 1866 \end{cfa} 1867 \\ 1868 \textbf{\CC:} 1869 & 1870 \begin{cfa} 1871 cout << x * 3 << y + 1 << `(`z << 2`)` << `(`x == y`)` << (x | y) << (x || y) << (x > z ? 1 : 2) << endl; 1872 \end{cfa} 1873 \\ 1874 \textbf{output:} 1875 & 1876 \begin{cfa}[showspaces=true,aboveskip=0pt] 1877 3 3 12 0 3 1 2 1878 \end{cfa} 1879 \end{tabular} 1880 \lstMakeShortInline@% 1881 \end{cquote} 1882 There is a weak similarity between the \CFA logical-or operator and the Shell pipe-operator for moving data, where data flows in the correct direction for input but the opposite direction for output. 1883 1884 The implicit separator character (space/blank) is a separator not a terminator. 1885 The rules for implicitly adding the separator are: 1886 \begin{list}{\footnotesize$\bullet$}{\itemsep=2pt\parsep=0pt} 1887 \item 1888 A separator does not appear at the start or end of a line. 1889 \item 1890 A separator does not appear before or after a character literal or variable. 1891 \item 1892 A separator does not appear before or after a null (empty) C string, which is a local mechanism to disable insertion of the separator character. 1893 \item 1894 A separator does not appear before a C string starting with the characters: \lstinline[mathescape=off,basicstyle=\tt]@([{=$@ 1895 \item 1896 A seperator does not appear after a C string ending with the characters: \lstinline[basicstyle=\tt]@,.;!?)]}%@ 1897 \item 1898 {\lstset{language=CFA,deletedelim=**[is][]{`}{`}} 1899 A seperator does not appear before or after a C string begining/ending with the quote or whitespace characters: \lstinline[basicstyle=\tt,showspaces=true]@`'": \t\v\f\r\n@ 1900 }% 1901 \item 1902 There are routines to set and get the separator string, and manipulators to toggle separation on and off in the middle of output. 1903 \end{list} 1904 1766 1905 1767 1906 \section{Evaluation}
Note: See TracChangeset
for help on using the changeset viewer.