\documentclass[nocolor,memo]{j3}
\renewcommand{\hdate}{11 July 2004}
\renewcommand{\vers}{J3/04-363}
\usepackage{lineno}
\usepackage{longtable}
\usepackage{xr}
\externaldocument{007}
\input pdftest
\begin{document}
\vspace{-10pt}
\begin{tabbing}
Subject: \hspace*{0.25in}\=Edits for .ANDTHEN. and .ORELSE.\\
From: \>Van Snyder\\
Reference: \>03-258r1, section 2.8.2; 04-193, 04-192, 04-357\\
\end{tabbing}
\pagewiselinenumbers
\leftlinenumbers
\linenumbers*
\section{Introduction}
The concept of \emph{and} and \emph{or} operators that are guaranteed to
short circuit evaluation was described in 03-258r1 and 04-193. On the
``hate it, dislike it, like it, love it'' scale it was rated 0, 1, 6, 3.
On the ``small, medium, large'' scale it was rated 9, 2, 0. JOR later
rated it ``medium.''
The brevity of the edits presented here suggest it really does belong at
``small.''
The precedence of .ANDTHEN.\ is proposed to be immediately below that of
.AND., while the precedence of .ORELSE.\ is proposed to be immediately
below that of .OR. If the precedence were the same, {\tt A .AND.\ B
.ANDTHEN.\ C} could be parsed as {\tt (A .AND.\ B) .ANDTHEN.\ C} or as
{\tt A .AND.\ (B .ANDTHEN.\ C)}. In the first case, one can be certain
that {\tt C} is not evaluated if either {\tt A} or {\tt B} is false. In
the second case, one can only be sure that {\tt C} is not evaluated if
{\tt B} is false. Similarly, {\tt A .ANDTHEN.\ B .AND.\ C} could be
parsed either as {\tt (A .ANDTHEN.\ B) .AND.\ C} or {\tt A .ANDTHEN.\ (B
.AND.\ C)}. In the first case, one can be certain that {\tt B} is not
evaluated if {\tt A} is false, while in the second case one can be
certain that neither {\tt B} nor {\tt C} is evaluated if {\tt A} is
false. Similar arguments apply to .ORELSE. The standard should not be
so ambiguous.
It is not proposed to put the precedence of .ANDTHEN.\ and .ORELSE.\
below .EQV.\ and .NEQV.\ because it is likely that programmers will
change .AND.\ to .ANDTHEN.\ or vice-versa, and similarly for .OR. and
.ORELSE.\ The reason to change AND.\ to .ANDTHEN.\ is a discovery that
something in the second operand is undefined if the first operand is
false. The reason for the opposite change is a discovery that everything
in the second operand is defined no matter whether the first operand is
false, and using .ANDTHEN.\ causes performance problems. Assuming the
parentheses used here to indicate precedence aren't actually present,
it would be unwise to arrange that {\tt (A .AND.\ B) .EQV.\ (C .AND.\ D)}
becomes {\tt A .ANDTHEN.\ (B .EQV.\ C) .ANDTHEN.\ D}, and vice-versa.
The semantical property of these operators that their second operand is
not evaluated if the first is false (true) could be provided by
conditional expressions (04-192) or a conditional-execution intrinsic
function (04-357), \emph{viz.} {\tt A .ANDTHEN.\ B} could be represented
{\tt A ? B :\ .FALSE.} or {\tt IF ( A, B, .FALSE.~)} and {\tt A .ORELSE.\
B} could be represented as {\tt A ? .TRUE.~:\ B} or {\tt IF ( A, .TRUE.,
B~)} . Thus, if the proposal for conditional expressions proceeds, this
proposal is somewhat redundant.
\edits{04-007}
\sep\mgpar{26:25+}\bnfx{719$\frac12$}{andthen-op}{.ANDTHEN.}
\sep\mgpar{26:26+}\bnfx{720$\frac12$}{orelse-op}{.ORELSE.}
\sep\mgpar{44:14}[Insert ``and .ANDTHEN.'' after ``.AND'' and ``and
.ORELSE.'' after ``.OR.''.]
\sep\mgpar{120:5-6}\bnfx{714$\frac12$}{andthen-operand}{[
\si{andthen-operand} \si{and-op} ] \si{and-operand}}\\
\bnfx{715}{or-operand}{[ \si{or-operand} \si{andthen-op} ]
\si{andthen-operand}}\\
\bnfx{715$\frac12$}{orelse-operand}{[ \si{orelse-operand} \si{or-op} ]
\si{or-operand}}\\
\bnfx{716}{equiv-operand}{[ \si{equiv-operand} \si{orelse-op} ]
\si{orelse-operand}}
\sep\mgpar{120:9+}\bnfx{719$\frac12$}{andthen-op}{.ANDTHEN.}
\sep\mgpar{120:10+}\bnfx{720$\frac12$}{orelse-op}{.ORELSE.}
\sep\mgpar{121:7+17}[Add ``, .ANDTHEN.'' after ``.AND.'' and ``, .ORELSE.''
after ``.OR.'' in the first column of Table 7.1.]
\sep\mgpar{121:20}[Add ``, .ANDTHEN.'' after ``.AND.'' and ``, .ORELSE.''
after ``.OR.''.]
\sep\mgpar{132:4}[Replace ``Once'' by ``For the .AND., .OR., .EQV., and
.NEQV. operators, once''.]
\sep\mgpar{132:8- New \P}For the .ANDTHEN. operator the processor shall
not evaluate the second operand if the first is false. For the .ORELSE.
operator, the processor shall not evalate the second operand if the first
is true. Otherwise, once the interpretation of an expression has been
established in accordance with the rules given in \ref{D7:Logical intrinsic
operations}, the processor may evaluate any other expression that is
logically equivalent, provided that the integrity of parentheses in any
expression is not violated.
\sep\mgpar{135:28+4,5+}[Insert two new rows in Table 7.5:]
\begin{longtable}{|lllp{1.9in}|}
.ANDTHEN. &
Logical conjunction&
$x_1$ .ANDTHEN. $x_2$&
True if $x_1$ and $x_2$ are both true, but $x_2$ shall not be
evaluated if $x_1$ is false\\
.ORELSE. &
Logical inclusive disjunction&
$x_1$ .ORELSE. $x_2$&
True if either $x_1$ or $x_2$ is true, but $x_2$ shall not be
evaluated if $x_1$ is true\\
\end{longtable}
\sep\mgpar{136:1+2+}[In the heading of Table 7.6, Add ``$x_1$ .ANDTHEN.
$x_2$'' under ``$x_1$ .AND. $x_2$'' and ``$x_1$ .ORELSE. $x_2$'' under
``$x_1$ .OR. $x_2$''.]
\sep\mgpar{136:5+13}[In Table 7.7, replace the .OR. row]
\begin{longtable}{|ccc|}
Logical & .ANDTHEN. & $\cdot$\\
Logical & .OR. & $\cdot$\\
Logical & .ORELSE. & $\cdot$\\
\end{longtable}
\label{lastpage}
\end{document}