aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/evalex.ht
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
committerdos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
commitab8cc85adde879fb963c94d15675783f2cf4b183 (patch)
treec202482327f474583b750b2c45dedfc4e4312b1d /src/hyper/pages/evalex.ht
downloadopen-axiom-ab8cc85adde879fb963c94d15675783f2cf4b183.tar.gz
Initial population.
Diffstat (limited to 'src/hyper/pages/evalex.ht')
-rw-r--r--src/hyper/pages/evalex.ht68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/hyper/pages/evalex.ht b/src/hyper/pages/evalex.ht
new file mode 100644
index 00000000..1a2eef3f
--- /dev/null
+++ b/src/hyper/pages/evalex.ht
@@ -0,0 +1,68 @@
+% Copyright The Numerical Algorithms Group Limited 1991.
+% Certain derivative-work portions Copyright (C) 1988 by Leslie Lamport.
+% All rights reserved
+
+\begin{page}{PrefixEval}{Example of Standard Evaluation}
+\beginscroll
+We illustrate the general evaluation of {\em op a} for some
+prefix operator {\em op} and operand {\em a}
+by the example: {\em cos(2)}.
+The evaluation steps are as follows:
+\vspace{1}\newline
+1.\tab{3}{\em a} evaluates to a value of some type.
+\newline\tab{3}{\em Example:} {\em 2} evaluates to {\em 2} of type \spadtype{Integer}
+\newline
+2.\tab{3}\Language{} then chooses a function {\em op} based on the type of {\em a}.
+\newline\tab{3}{\em Example:} The function {\em cos:} \spadtype{Float} {\em ->}
+\spadtype{Float} is chosen.
+\newline
+3.\tab{3}If the argument type of the function is different from that of {\em a},
+then the system coerces
+%\downlink{coerces}{Coercion}
+the value of {\em a} to the
+argument type.
+\newline\tab{3}{\em Example:} The integer {\em 2} is coerced to the float {\em 2.0}.
+\newline
+4.\tab{3}The function is then applied to the value of {\em a} to produce the value
+for {\em op a}.
+\newline\tab{3}{\em Example:} The function {\em cos} is applied to {\em 2.0}.
+\vspace{1}\newline
+Try it:
+\example{cos(2)}
+\endscroll
+\autobuttons\end{page}
+
+\begin{page}{InfixEval}{Example of Standard Evaluation}
+\beginscroll
+We illustrate the general evaluation of {\em a op b} for some
+infix operator {\em op} with operands {\em a} and {\em b}
+by the example: {\em 2 + 3.4}.
+The evaluation steps are as follows:
+\vspace{1}\newline
+1.\tab{3}{\em a} and {\em b} are evaluated, each producing a value and a type.
+\newline\tab{3}{\em Example:} {\em 2} evaluates to {\em 2} of type \spadtype{Integer};
+{\em 3.4} evaluates to {\em 3.4} of type \spadtype{Float}.
+\vspace{1}\newline
+2.\tab{3}\Language{} then chooses a function {\em op} based on the types of {\em a} and {\em b}.
+\newline\tab{3}{\em Example:} The function {\em +: (D,D) -> D}
+is chosen requiring a common type {\em D} for both arguments to {\em +}.
+An operation called {\em resolve} determines the `smallest common type' \spadtype{Float}.
+\vspace{1}\newline
+3.\tab{3}If the argument types for the function are different from
+those of {\em a} and {\em b},
+then the system coerces
+%\downlink{coerces}{Coercion}
+the values to the argument types.
+\newline\tab{3}{\em Example:} The integer {\em 2} is coerced to the float {\em 2.0}.
+\vspace{1}\newline
+4.\tab{3}The function is then applied to the values of {\em a} and {\em b}
+to produce the value for {\em a op b}.
+\newline\tab{3}{\em Example:} The function {\em +: (D,D) -> D}, where
+{\em D} = \spadtype{Float} is applied to {\em 2.0} and {\em 3.4} to produce {\em 5.4}.
+\vspace{1}\newline
+Try it:
+\example{2 + 3.4}
+\endscroll
+\autobuttons\end{page}
+
+