News for hackers. Stuff that matters.
Re:Forth: Stack-Manipulation Operators by kragen on Friday May 14, 2021 @08:47PM (#27161204)
> 0 VALUE C : CAB TO C - C / ; or possibly VARIABLE C : CAB C ! - C @ / ;

This is wrong. It should be

    0 VALUE C  0 VALUE D
    : CAB - TO D TO C  D C / ;
or

    VARIABLE C  VARIABLE D
    : CAB - D ! C !  D @ C @ / ;
Incidentally, that's exactly how I implemented DUP, DROP, and SWAP in StoneKnifeForth:

    var X # 0  var Y # 0  ( temp vars )
    : dup  X !  X @  X @ ;  : pop X ! ;  : xchg X !  Y !  X @  Y @ ; ( SWAP/exch )
(The weird names are because only the first byte of the name is significant in SKF.)

There are no comments on this comment yet.