Skip to content

[spec] Fix block values #609

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

Merged
merged 1 commit into from
Nov 30, 2017
Merged
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
16 changes: 7 additions & 9 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -964,24 +964,22 @@ Exiting :math:`\instr^\ast` with label :math:`L`

When the end of a block is reached without a jump or trap aborting it, then the following steps are performed.

1. Let :math:`n` be the arity of :math:`L`.
1. Let :math:`m` be the number of values on the top of the stack.
Copy link
Member

Choose a reason for hiding this comment

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

I know what you mean by "values on top of the stack", but is that mentioned anywhere in the spec?

Copy link
Member Author

Choose a reason for hiding this comment

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

The runtime section defines the stack. Although never defined explicitly, the spec mentions "the top of the stack" in various places. Do you think it might be too unclear?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's probably fine when it's just a few values. This case is perhaps a little less clear since you're only counting up from the label. That said, the formula below makes it explicit.


2. Assert: due to :ref:`validation <valid-instr-seq>`, there are :math:`n` values on the top of the stack.
2. Pop the values :math:`\val^m` from the stack.

3. Pop the results :math:`\val^n` from the stack.
3. Assert: due to :ref:`validation <valid-instr-seq>`, the label :math:`L` is now on the top of the stack.

4. Assert: due to :ref:`validation <valid-instr-seq>`, the label :math:`L` is now on the top of the stack.
4. Pop the label from the stack.

5. Pop the label from the stack.
5. Push :math:`\val^m` back to the stack.

6. Push :math:`\val^n` back to the stack.

7. Jump to the position after the |END| of the :ref:`structured control instruction <syntax-instr-control>` associated with the label :math:`L`.
6. Jump to the position after the |END| of the :ref:`structured control instruction <syntax-instr-control>` associated with the label :math:`L`.

.. math::
~\\[-1ex]
\begin{array}{lcl@{\qquad}l}
\LABEL_n\{\instr^\ast\}~\val^n~\END &\stepto& \val^n
\LABEL_n\{\instr^\ast\}~\val^m~\END &\stepto& \val^m
\end{array}

.. note::
Expand Down