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
Clarify elsewhen initial #2647
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing major, just some comments.
chapters/equations.tex
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps when-statements would be more to the point, and the see below probably only refers to these?
\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 | |
(where \lstinline!when! may be replaced by \lstinline!elsewhen!) \lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then! (and similarly for when-statements, see below). In this case, the when-clause equations remain active during the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I first considered a text like that, but I didn't like it since there is a slight difference between elsewhen and when, in that when is always first - and I wanted to delay those obscure cases. The elsewhen-part below handles both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it just seems unfortunate that when
/elsewhen
causes a lack of symmetry that is only syntactical. This is why I ended up with the formulation suggested below (if and only if they are the first clause…) that captures the symmetry of the semantics.
That means that any subsequent \lstinline!elsewhen initial()! has no effect, | ||
similarly as \lstinline!when false then!. |
There was a problem hiding this comment.
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?
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. |
There was a problem hiding this comment.
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.
@@ -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 |
There was a problem hiding this comment.
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?
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!. |
There was a problem hiding this comment.
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()!, …
Remove double space. Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
I'll merge it for now and we can then later improve the formulation. |
Closes #2636