I tried grepping through the 15 or 20 Forth systems that I have
source for, but neither "over swap" nor the stack effect turned up
any definitions for it.
--Josh
Rob Chapman, the inventer of Timbre, called that NUP .
It isn't commonly used. TUCK is used far more often.
I thought TUCK is used for SWAP OVER.
--
Marc
Yes, it is. And it's used far more often than NUP which does OVER SWAP .
DUP performs x1 x2 -- x1 x2 x2
Why not -DUP x1 x2 -- x1 x1 x2
In analogy to ROT and -ROT.
And silently forget about old standards ;-)
--
Coos
CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html
In Factor it is called DDUP. I would recommend using this even if you
think that it is unintuitive, just for the sake of being compatible
with Factor.
I spend a fair amount of time porting programs between Forth and
Factor, so any effort at making them similar helps.
Common name? ...
Philip Koopman UNDER
Rob Chapman NUP
This question has come up previously. E.g., it's the topic of "Any
'standard' names for.." thread Jan 7,2008 in c.l.f. That's a link to the
first post. It'll let you get to the entire thread.:
http://groups.google.com/group/comp.lang.forth/msg/1972c85309733f91?hl=en
Rob Chapman created six "Quarks", including NUP. Basically, they are used
to keep the top two data stack elements in registers.
http://clubweb.interbaun.com/~rc/Timbre/ContentPages/Timbre/SQP/StackQuarksPaper.html
http://clubweb.interbaun.com/~rc/Timbre/
Philip Koopman tested UNDER (and some others) in his paper "A Preliminary
Exploration of Optimized Stack Code Generation".
http://www.ece.cmu.edu/~koopman/stack_compiler/stack_co.pdf
Rod Pemberton
It's actually called dupd in Factor. This name comes from the Joy
language (its a mnemonic for [ dup ] dip). However we're phasing out
dupd and a few other 'complex' stack shuffle operations, like rot and -
rot. We've already removed tuck.
Slava
> It's actually called dupd in Factor. This name comes from the Joy
> language (its a mnemonic for [ dup ] dip). However we're phasing out
> dupd and a few other 'complex' stack shuffle operations, like rot and -
> rot. We've already removed tuck.
Oops! I put the extra D on the wrong end.
Most Factor code does use DIP and so forth, rather than stack
manipulators. I'm still struggling to get a hang of that style of
stack-manipulation.
Wonderful! This is surely a case when removing a feature improves the
quality of a programming language. The small number of stack
manipulation operators in Forth is a feature, not a bug.
Andrew.
Factor can phase out stack shuffle operations because it has
quotations, which allow it to use DIP and other similar words. It is
arguable whether DIP and its ilk are more or less readable than TUCK
and its ilk. This argument is a meaningless in the context of
comp.lang.forth howver, because ANS-Forth doesn't have quotations, so
we can't switch to DIP etc. even if we wanted to.
[ stuff ] dip
is pretty much equivalent to
>r stuff r>
in Forth. The secondary stack is a handy tool.
Ian
> Is there a common name for OVER SWAP?
I've met "PLEAT" in "FIG Forth, v.2." somewhere in Taygeta archive.
> I can't think of a good
> name for it, which argues for leaving it as an idiom. But I find
> that it (like BOUNDS) turns up just often enough for me to wonder
> whether it should have a name...
>
> I tried grepping through the 15 or 20 Forth systems that I have
> source for, but neither "over swap" nor the stack effect turned up
> any definitions for it.
--
HE CE3OH...