Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /trunk/doc/report/lang.tex
ViewVC logotype

Diff of /trunk/doc/report/lang.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 330, Thu Aug 19 02:57:31 2010 UTC revision 473, Thu Nov 4 15:34:51 2010 UTC
# Line 20  Line 20 
20    
21  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22  \section{Statements}  \section{Statements}
23    
24    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25    \section{Expressions}
26    
27    \subsection{Conditional expressions}
28    There are three conditional expression forms in Diderot:
29    \emph{if-else} expressions, \emph{or-else} expressions, and \emph{and-also}
30    expressions.
31    The syntax of these is given by the following grammar fragment:
32    \begin{Grammar}
33      \ExprRULES{}
34      \TestExprRULES{}
35      \AndExprRULES{}
36    \end{Grammar}%
37    
38    \subsubsection{If-else expressions}
39    The if-else expression has the following typing rule:
40    \begin{displaymath}
41      \infer{
42          \HasTy{\ENV}{e_1\;\mkw{if}\;e_2\;\mkw{else}\;e_3}{\tau}
43        }{
44          \HasTy{\ENV}{e_1}{\tau} \quad
45          \HasTy{\ENV}{e_2}{\TYbool} \quad
46          \HasTy{\ENV}{e_3}{\tau} \quad
47      }
48    \end{displaymath}%
49    Its semantics are that it evaluates $e_2$ first.
50    If the value is true, then it evaluate $e_1$, otherwise it evaluates $e_3$.
51    
52    \subsubsection{Or-else expressions}
53    \begin{displaymath}
54      \infer{
55          \HasTy{\ENV}{e_1\;\mkw{||}\;e_2}{\TYbool}
56        }{
57          \HasTy{\ENV}{e_1}{\TYbool} \quad
58          \HasTy{\ENV}{e_2}{\TYbool}
59      }
60    \end{displaymath}%
61    The or-else form is derived from the if-else form as follows:
62    \begin{displaymath}
63      e_1\;\mkw{||}\;e_2 \quad \equiv \quad \mkw{true}\;\mkw{if}\;e_1\;\mkw{else}\;e_2
64    \end{displaymath}%
65    
66    \subsubsection{If-else expressions}
67    \begin{displaymath}
68      \infer{
69          \HasTy{\ENV}{e_1\;\mkw{\&\&}\;e_2}{\TYbool}
70        }{
71          \HasTy{\ENV}{e_1}{\TYbool} \quad
72          \HasTy{\ENV}{e_2}{\TYbool}
73      }
74    \end{displaymath}%
75    The and-also form is derived from the if-else form as follows:
76    \begin{displaymath}
77      e_1\;\mkw{\&\&}\;e_2 \quad \equiv \quad e_2\;\mkw{if}\;e_1\;\mkw{else}\;\mkw{false}
78    \end{displaymath}%
79    
80    \subsection{Binary expressions}
81    \begin{Grammar}
82      \CmpExprRULES{}
83      \AddExprRULES{}
84      \MulExprRULES{}
85      \CmpOpRULES{}
86      \AddOpRULES{}
87      \MulOpRULES{}
88    \end{Grammar}%
89    
90    \subsection{Field-probe expressions}
91    \begin{Grammar}
92      \ProbeExprRULES{}
93    \end{Grammar}%
94    
95    \subsection{Unary expressions}
96    \begin{Grammar}
97      \PrefixExprRULES{}
98    \end{Grammar}%
99    
100    \subsection{Tensor-slice expressions}
101    \begin{Grammar}
102      \SliceExprRULES{}
103      \IndexRULES{}
104    \end{Grammar}%
105    
106    \subsection{Atomic expressions}
107    \begin{Grammar}
108      \AtomExpRULES{}
109      \ArgumentsRULES{}
110    \end{Grammar}%

Legend:
Removed from v.330  
changed lines
  Added in v.473

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0