Proposal: Specify that 0 THROW pops the 0

Accepted

This page is dedicated to discussing this specific proposal

ContributeContributions

AntonErtlavatar of AntonErtl [213] Specify that 0 THROW pops the 0Proposal2021-09-11 12:25:15

Hint: Please delete the blockquote explanations, they are just for your convenience while writing the proposal

Author:

M. Anton Ertl

Change Log:

First version

Problem:

The specification of THROW does not say that it pops the 0 on 0 THROW

Solution:

The following is a minimal fix. If somebody is willing to give THROW a more substantial rework, go ahead

Typical use: (Optional)

... search-wordlist 0= -13 and throw execute

Proposal:

Behind the stack effect of 9.6.1.2275 THROW, insert

Remove n from the stack.

AntonErtlavatar of AntonErtlNew Version: Specify that 0 THROW pops the 0

Hide differences

Hint: Please delete the blockquote explanations, they are just for your convenience while writing the proposal

Author:

M. Anton Ertl

Change Log:

First version

This version proposes a less minimal change, resulting after discussions at the 2022i meeting

Problem:

The specification of THROW does not say that it pops the 0 on 0 THROW

The specification of THROW does not say what happens on 0 THROW

Solution:

Solution

The following is a minimal fix. If somebody is willing to give THROW a more substantial rework, go ahead

This is still a pretty minimal change. A more subtantial rework would move the input stream handling elsewhere in the standard (this has come up as a cause for confusion). Moreover, I think the organization of the various cases is suboptimal. A better approach might be

  • n=0
  • n!=0
    • exception stack non-empty
    • exception stack empty
      • n=-1
      • n=-2
      • otherwise

If you want (or don't want) such changes, reply to this proposal.

Typical use: (Optional)

... search-wordlist 0= -13 and throw execute

Proposal:

Behind the stack effect of 9.6.1.2275 THROW, insert

Remove n from the stack.

If all bits of n are zero, remove n from the stack and continue execution behind the THROW.

Formal

ruvavatar of ruv

If all bits of n are zero, remove n from the stack and continue execution behind the THROW.

The phrase "continue execution" is used in descriptions of run-time semantics only (for example, see IF).

For execution semantics the phrase "do nothing" is used (for example, see [IF][<sup>1]).

So a better wording is:

If all bits of n are zero, remove n from the stack and do nothing more.


[<sup>1] For [IF] it could also say "remove flag from the stack", since otherwise it looks like a mismatch of the stack diagram and the text of the semantic description (see also 2.2.4.2 Glossary semantic description; a stack diagram is a normative part of a semantic description).

ruvavatar of ruv

If you want (or don't want) such changes, reply to this proposal.

I want such changes. In the current wording some important nuances are unclear (see also a recent discussion in ForthHub)

ruvavatar of ruv

In the frame of a big re-organization of THROW specification, the following phrase should be also corrected:

If any bits of n are non-zero, pop the topmost exception frame from the exception stack, along with everything on the return stack above that frame.

The part "along with everything on the return stack above that frame" should be removed, since it implies that the exception stack is implemented using the return stack.

The return stack depth is restored according to the part "adjust the depths of all stacks defined by this standard so that they are the same as the depths saved in the exception frame".

Also, the specification for CATCH should require it to save in the exception frame the depth of all stacks defined by this standard .

AntonErtlavatar of AntonErtlNew Version: Specify that 0 THROW pops the 0

Hide differences

Author:

M. Anton Ertl

Change Log:

This version proposes a less minimal change, resulting after discussions at the 2022i meeting

Problem:

The specification of THROW does not say what happens on 0 THROW

Solution

This is still a pretty minimal change. A more subtantial rework would move the input stream handling elsewhere in the standard (this has come up as a cause for confusion). Moreover, I think the organization of the various cases is suboptimal. A better approach might be

  • n=0
  • n!=0
    • exception stack non-empty
    • exception stack empty
      • n=-1
      • n=-2
      • otherwise

If you want (or don't want) such changes, reply to this proposal.

Typical use: (Optional)

... search-wordlist 0= -13 and throw execute

Proposal:

Behind the stack effect of 9.6.1.2275 THROW, insert

If all bits of n are zero, remove n from the stack and continue execution behind the THROW.

If all bits of n are zero, remove n from the stack and continue execution after the THROW.

AntonErtlavatar of AntonErtl

Accepted at the 2022 meeting 10Y:0N:1A

Accepted
Reply New Version