Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 85 additions & 25 deletions source/lib-intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -495,37 +495,92 @@

\pnum
Descriptions of function semantics contain the following elements (as
appropriate):\footnote{To save space, items that do not apply to a function are omitted.
For example, if a function does not specify any
further
preconditions, there will be no \requires paragraph.}
appropriate):\footnote{To save space, elements that do not apply to a function are omitted.
For example, if a function specifies no
preconditions, there will be no \expects element.}

\begin{itemize}
\item \requires the preconditions for calling the function
\item \effects the actions performed by the function
\item \sync the synchronization operations\iref{intro.multithread} applicable to the function
\item \postconditions the observable results established by the function
\item \returns a description of the value(s) returned by the function
\item \throws any exceptions thrown by the function, and the conditions that would cause the exception
\item \complexity the time and/or space complexity of the function
\item \remarks additional semantic constraints on the function
\item \errors the error conditions for error codes reported by the function
\item
\requires the preconditions for calling the function.

\item
\constraints the conditions for the function's participation
in overload resolution\iref{over.match}.
\begin{note}
Failure to meet such a condition results in the function's silent non-viability.
\end{note}
\begin{example}
An implementation might express such a condition
via a \grammarterm{constraint-expression}\iref{temp.constr.decl}.
\end{example}

\item
\mandates the conditions that, if not met, render the program ill-formed.
\begin{example}
An implementation might express such a condition
via the \grammarterm{constant-expression}
in a \grammarterm{static\_assert-declaration}\iref{dcl.dcl}.
If the diagnostic is to be emitted only after the function
has been selected by overload resolution,
an implementation might express such a condition
via a \grammarterm{constraint-expression}\iref{temp.constr.decl}
and also define the function as deleted.
\end{example}

\item
\expects the conditions (sometimes termed preconditions)
that the function assumes to hold whenever it is called.
\begin{example}
An implementation might express such conditions
via an attribute such as \tcode{[[expects]]}\iref{dcl.attr.contract}.
However, some such conditions might not lend themselves
to expression via code.
\end{example}

\item
\effects the actions performed by the function.

\item
\sync the synchronization operations\iref{intro.multithread} applicable to the function.

\item
\ensures the conditions (sometimes termed observable results or postconditions)
established by the function.

\item
\returns a description of the value(s) returned by the function.

\item
\throws any exceptions thrown by the function, and the conditions that would cause the exception.

\item
\complexity the time and/or space complexity of the function.

\item
\remarks additional semantic constraints on the function.

\item
\errors the error conditions for error codes reported by the function.
\end{itemize}

\pnum
Whenever the \Fundescx{Effects} element specifies that the semantics of some function
\tcode{F} are \term{Equivalent to} some code sequence, then the various elements are
interpreted as follows. If \tcode{F}'s semantics specifies a \Fundescx{Requires} element, then
that requirement is logically imposed prior to the \term{equivalent-to} semantics.
Next, the semantics of the code sequence are determined by the \Fundescx{Requires}, \Fundescx{Effects},
\Fundescx{Synchronization}, \Fundescx{Postconditions}, \Fundescx{Returns}, \Fundescx{Throws}, \Fundescx{Complexity}, \Fundescx{Remarks}, and \Fundescx{Error conditions}
specified for the function invocations contained in the code sequence. The value
returned from \tcode{F} is specified by \tcode{F}'s \Fundescx{Returns} element, or if \tcode{F}
has no \Fundescx{Returns} element, a non-\tcode{void} return from \tcode{F} is specified by the
interpreted as follows.
If \tcode{F}'s semantics specifies any \Fundescx{Constraints} or \Fundescx{Mandates} elements,
then those requirements are logically imposed prior to the \term{equivalent-to} semantics.
Next, the semantics of the code sequence are determined by the
\Fundescx{Constraints}, \Fundescx{Mandates}, \Fundescx{Expects}, \Fundescx{Effects},
\Fundescx{Synchronization}, \Fundescx{Ensures}, \Fundescx{Returns}, \Fundescx{Throws},
\Fundescx{Complexity}, \Fundescx{Remarks}, and \Fundescx{Error conditions}
specified for the function invocations contained in the code sequence.
The value returned from \tcode{F} is specified by \tcode{F}'s \Fundescx{Returns} element,
or if \tcode{F} has no \Fundescx{Returns} element,
a non-\tcode{void} return from \tcode{F} is specified by the
\tcode{return} statements\iref{stmt.return} in the code sequence.
If \tcode{F}'s semantics contains a \Fundescx{Throws},
\Fundescx{Postconditions}, or \Fundescx{Complexity} element, then that supersedes any occurrences of that
element in the code sequence.
\Fundescx{Ensures}, or \Fundescx{Complexity} element,
then that supersedes any occurrences of that element in the code sequence.

\pnum
For non-reserved replacement and handler functions,
Expand Down Expand Up @@ -2737,11 +2792,16 @@

\pnum
\indextext{restriction}%
Violation of the preconditions specified in a function's
Violation of any preconditions specified in a function's
\requires
paragraph results in undefined behavior unless the function's
element results in undefined behavior unless the function's
\throws
paragraph specifies throwing an exception when the precondition is violated.
element specifies throwing an exception when the precondition is violated.

\pnum
Violation of any preconditions specified
in a function's \expects element
results in undefined behavior.

\rSec2[conforming]{Conforming implementations}

Expand Down
6 changes: 5 additions & 1 deletion source/macros.tex
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,12 @@
\newcommand{\Fundesc}[1]{\Fundescx{#1:}\space}
\newcommand{\required}{\Fundesc{Required behavior}}
\newcommand{\requires}{\Fundesc{Requires}}
\newcommand{\constraints}{\Fundesc{Constraints}}
\newcommand{\mandates}{\Fundesc{Mandates}}
\newcommand{\expects}{\Fundesc{Expects}}
\newcommand{\effects}{\Fundesc{Effects}}
\newcommand{\postconditions}{\Fundesc{Postconditions}}
\newcommand{\ensures}{\Fundesc{Ensures}}
\newcommand{\postconditions}{\ensures}
\newcommand{\returns}{\Fundesc{Returns}}
\newcommand{\throws}{\Fundesc{Throws}}
\newcommand{\default}{\Fundesc{Default behavior}}
Expand Down