Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify elsewhen initial #2647

Merged
merged 2 commits into from Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion chapters/equations.tex
Expand Up @@ -748,7 +748,7 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali
(such as simulation or linearization).

The equations of a when-clause are active during initialization, if and only if they are explicitly enabled with \lstinline!initial()!, and only in one of the two forms
\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then! (and similarly for algorithms see below). In this case, the when-clause equations remain active during the
\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then! (and similarly for \lstinline!elsewhen! and algorithms see below). In this case, the when-clause equations remain active during the
whole initialization phase. In case of a \lstinline!reinit(x, expr)! being active during initialization (due to being inside \lstinline!when initial()!) this is interpreted as adding
\lstinline!x = expr! (the \lstinline!reinit!-equation) as an initial equation.

Expand All @@ -762,6 +762,15 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali
\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!. In this case, the algorithmic statements within the when-statement remain active during the whole
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose there should be an elsewhen clarification here as well, preserving the symmetry with the when-equations?

initialization phase.

An active when-clause inactivates the following \lstinline!elsewhen! (similarly as for when-clauses during simulation), but apart from that
the first \lstinline!elsewhen initial() then! or \lstinline!elsewhen {$\ldots$, initial(), $\ldots$} then! is similarly active during initialization as
\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!.
Comment on lines +765 to +767
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, maybe this was also included among the intended references of the see below above?

I think we can say this more directly, if we go back to the first sentence:

The equations of a when-clause are active during initialization, if and only if they are the first clause of the when-equation explicitly enabled with \lstinline!initial()!, …


\begin{nonnormative}
That means that any subsequent \lstinline!elsewhen initial()! has no effect,
similarly as \lstinline!when false then!.
Comment on lines +770 to +771
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we go as far as to speak of warnings?

Suggested change
That means that any subsequent \lstinline!elsewhen initial()! has no effect,
similarly as \lstinline!when false then!.
A tool may warn in case an \lstinline!initial()! condition cannot activate its when-clause due to an earlier when-clause already being active during initialization.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered it, but there are (as indicated) other similar cases as well, and to me it looks odd if we discuss warnings for the obscure cases - and not for the simple ones; and thought it sufficed to say that it has no effect.

\end{nonnormative}

\begin{nonnormative}
There is no special handling of inactive when-statements during initialization, instead
variables assigned in when-statements are initialized using \lstinline!v := pre(v)!
Expand Down