From Newsgroup: comp.lang.forth
dxf wrote:
On 1/12/2023 9:04 pm, albert wrote:
In article <ukalqa$1fmfg$1@dont-email.me>,
Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
I'm in need of a convenient way to do the following for the fp stack,
but we can pose the problem for the data stack:
[..]
The presence of ROT SWAP ought to raise a red flag as it suggests
something is awry. After examining the code we may conclude its
use in this case was the least worst option.
I can only find it 50 times in 1352 files. It seems to pop up
when there are 3 strong-coupled parameters for a certain operation
(like your MOVE).
The classic HANOI demo uses it:
hanoi.frt(53): -rot swap r@ 1- recurse \ extra dest source N-1
hanoi.frt(55): -rot swap r>
hanoi.frt(87): >r -rot swap r> 1- recurse exit \ extra dest source N-1 hanoi.frt(359): -ROT SWAP R@ 1- RECURSE \ EXTRA DEST SOURCE n-1 hanoi.frt(361): -ROT SWAP R>
hanoi.frt(375): >R -ROT SWAP R> 1- RECURSE \ EXTRA DEST SOURCE n-1 hanoi.frt(507): . -ROT SWAP R@ 1- RECURSE \ EXTRA DEST SOURCE n-1 hanoi.frt(509): . -ROT SWAP R>
The TAK test has the same coupling problem:
tak.frt(8): : tak2 ( x y z -- y1- z x ) swap 1- -rot swap ;
This classic utility (almost) mirrors your example:
blocks\editor.frt(109): -ROT SWAP CMOVE
Classic integer FFT
numeric\fft.frt(22): : X- ROT SWAP - -ROT - SWAP ; ( cplx1 cplx2 -- cplx3 )
Somebody remembers SOD64 ?
sod64\kernel.frt(236): R> ROT ROT SWAP >R >R >R ;
sod64\kernel.frt(240): OVER OVER - IF R> ROT ROT SWAP >R >R 8 + >R sod64\kernel.frt(814): 1+ ROT ROT SWAP 1- SWAP
sod64\kernel.frt(825): 1+ ROT ROT SWAP 1- SWAP
Too low a frequency to make it a new word (and then having to look it up).
-marcel
--- Synchronet 3.20a-Linux NewsLink 1.114