Digest #160 2021-08-21
Contributions
GI5 don't compile correctly. To cope with subsequent test it should be as follow.
T{ : GI5 DUP 2 > IF BEGIN
DUP 5 < WHILE DUP 1+ REPEAT
123 ELSE 345 THEN ; -> }T
Replies
I hit a similar problem and think it would be better not to depend on START-DEPTH instead
T{ DEPTH DEPTH - -> -1 }T
T{ DEPTH 0 SWAP DEPTH - -> 0 -1 }T
T{ DEPTH 0 1 ROT DEPTH - -> 0 1 -2 }T
@MitraArdron : I agree with you ! I've tried your suggestions and I have to say the last two don't work because the final negative literal is one off. They should be:
T{ DEPTH 0 SWAP DEPTH - -> 0 -2 }T
T{ DEPTH 0 1 ROT DEPTH - -> 0 1 -3 }T
Then, following your method, I would add some more:
T{ DEPTH 9 8 -> 9 8 DEPTH 2 - ROT ROT }T
T{ DEPTH 9 -> 9 DEPTH 1 - SWAP }T
T{ 9 DEPTH -> DEPTH 9 SWAP 1 + }T
T{ 9 8 DEPTH -> DEPTH 9 8 ROT 2 + }T
requestClarification - Why "[" is specified using immediacy?
Read it in reverse, [ is the only word this Standard explicitly declares IMMEDIATE and whose Interpretation semantics are undefined.
In this perspective [ is a most peculiar word that cannot be easily compared with other words with undefined interpretation semantics such as IF or others alike because [ is not STATE-dependant like them: in fact it is the opposite i.e. STATE is [-dependant since STATE is modified by [ independantly from what the current (value of) STATE is.
AFAIK there is only one more word this Standard explicitly declares IMMEDIATE i.e. \ the comment till EOL.
Both [ and \ (if you want them to perform their duty and you aren't creating some special word) just cannot be compiled and the only way to accpmplish this is having them IMMEDIATE.
Having ] undefined interpretation semantics seems a bit misleading but it IMHO means that there is no reason or no useful effect to use it while not compiling.
Matteo
GI5 don't compile correctly. To cope with subsequent tests it should be as follow.
T{ : GI5 DUP 2 > IF BEGIN
DUP 5 < WHILE DUP 1+ REPEAT
123 ELSE 345 THEN ; -> }T