Krishna Myneni
2023-11-30 18:55:04 UTC
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:
a b c -- b a c
Two ways to do this on the data stack are
ROT SWAP
Is there a word I'm not remembering to perform this operation? If not
what name would one give to this stack operation?
SWAP-UNDER
ROTSWAP
RISE
For fp stack manipulation, I had posted mostly portable code for F>R and
FR> to push and pop from the floating point stack to/from the return
stack. A significant reason for suggesting the F>R FR> pair is to deal
with this situation where having to use FROT FSWAP would be inefficient
on non-analytic compilers.
Maybe a generic swap operation at depth u, called RISE, is useful e.g.
0 RISE \ same as SWAP
1 RISE \ i*x a b c -- i*x b a c
2 RISE \ i*x a b c d -- i*x b a c d
etc.
Comments?
--
Krishna Myneni
but we can pose the problem for the data stack:
a b c -- b a c
Two ways to do this on the data stack are
ROT SWAP
R SWAP R>
( the latter can't be done from the interpreter, portably at least ).Is there a word I'm not remembering to perform this operation? If not
what name would one give to this stack operation?
SWAP-UNDER
ROTSWAP
RISE
For fp stack manipulation, I had posted mostly portable code for F>R and
FR> to push and pop from the floating point stack to/from the return
stack. A significant reason for suggesting the F>R FR> pair is to deal
with this situation where having to use FROT FSWAP would be inefficient
on non-analytic compilers.
Maybe a generic swap operation at depth u, called RISE, is useful e.g.
0 RISE \ same as SWAP
1 RISE \ i*x a b c -- i*x b a c
2 RISE \ i*x a b c d -- i*x b a c d
etc.
Comments?
--
Krishna Myneni