Digest #25 2018-01-08

Contributions

[37] 2018-01-06 18:08:55 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: FILL -ROT 0 ?DO 2DUP C! 1+ LOOP 2DROP ;


[38] 2018-01-06 18:10:48 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: 2DROP DROP DROP ;


[39] 2018-01-06 18:11:16 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: 2DUP OVER OVER ;


[40] 2018-01-06 18:12:03 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: 2SWAP >R -ROT R> -ROT ;


[41] 2018-01-06 18:13:14 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: 2OVER 2>R 2DUP 2R> 2SWAP ;


[42] 2018-01-06 18:13:51 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: OVER >R DUP R> SWAP ;


[43] 2018-01-06 18:15:17 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: TYPE 0 MAX 0 ?DO DUP C@ EMIT 1+ LOOP DROP ;


[44] 2018-01-06 18:17:01 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: ['] IMMEDIATE ' POSTPONE LITERAL ;


[45] 2018-01-06 18:18:19 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: [CHAR] IMMEDIATE CHAR POSTPONE LITERAL ;


[46] 2018-01-06 18:19:18 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: HEX 16 BASE !


[47] 2018-01-06 18:20:21 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: NIP SWAP DROP ;


[48] 2018-01-06 18:20:49 NieDzejkob wrote:

referenceImplementation - Suggested reference implementation

: TUCK SWAP OVER ;

Replies

[r91] 2017-10-31 12:26:22 AntonErtl replies:

proposal - The value of STATE should be restored

Not every CATCH needs to be wrapped, only code that changes STATE. If you have a word that changes and has to restore STATE, use a STATE-wrapper. All other CATCHes are unaffected. Because the INCLUDED can change STATE, use a STATE-wrapper for the INCLUDED in your example.

The cited statement from the rationale is about what happens on the stack, and is unrelated to other state.

A system that saves and restores STATE on a CATCH would not be standard, because it would do programmer-visible things that are not specified in the standard.


[r92] 2017-11-01 14:08:50 StephenPelc replies:

proposal - The value of STATE should be restored

The current definition of CATCH and THROW is deliberately minimal. I believe that it should stay minimal. An embedded system may use CATCH/THROW but not have STATE or BASE.

We (MPE) have attempted in the past to cope with customer wishes for extended facilities. 30 years later we regret all these concessions. The best that we could do now is to DEFER CATCH and THROW.

In the given use case (INCLUDED and friends), the most likely action of the final error handler is to leave compilation and perform some form of restart. We also have plenty of instances in which errors are rethrown because the CATCH/THROW mechanism itself is used to ensure state recovery at several levels. In this case, putting a CATCH inside INCLUDED and then throwing again permits STATE restoration, and no specification change for CATCH is required.


[r93] 2018-01-07 18:03:35 AntonErtl replies:

referenceImplementation - Suggested reference implementation

IMMEDIATE itself is not immediate, so Bernd Paysan's reference implementation is correct, and it contains a stack effect comment.


[r94] 2018-01-07 18:05:20 AntonErtl replies:

referenceImplementation - Suggested reference implementation

IMMEDIATE is not immediate, so this won't work. A working version is:

: ['] ( compilation: "name" --; run-time: -- xt ) ' POSTPONE literal ; immediate