Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there a common name for OVER SWAP?

34 views
Skip to first unread message

Josh Grams

unread,
Nov 27, 2009, 8:14:53 AM11/27/09
to
Is there a common name for OVER SWAP? 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.

--Josh

Jonah Thomas

unread,
Nov 27, 2009, 8:38:02 AM11/27/09
to
Josh Grams <jo...@qualdan.com> wrote:

Rob Chapman, the inventer of Timbre, called that NUP .

It isn't commonly used. TUCK is used far more often.

Marc Olschok

unread,
Nov 27, 2009, 1:14:05 PM11/27/09
to

I thought TUCK is used for SWAP OVER.

--
Marc

Jonah Thomas

unread,
Nov 27, 2009, 2:37:57 PM11/27/09
to

Yes, it is. And it's used far more often than NUP which does OVER SWAP .

Coos Haak

unread,
Nov 27, 2009, 8:41:29 PM11/27/09
to
Op Fri, 27 Nov 2009 13:14:53 GMT schreef Josh Grams:

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

Hugh Aguilar

unread,
Nov 27, 2009, 11:31:42 PM11/27/09
to

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.

Rod Pemberton

unread,
Nov 28, 2009, 2:43:50 AM11/28/09
to
"Josh Grams" <jo...@qualdan.com> wrote in message
news:hhQPm.27590$Sw5....@newsfe16.iad...

> Is there a common name for OVER SWAP?

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


Slava Pestov

unread,
Nov 28, 2009, 7:05:23 PM11/28/09
to
On Nov 27, 10:31 pm, Hugh Aguilar <hugoagui...@rosycrew.com> wrote:
> 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.

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

Hugh Aguilar

unread,
Nov 28, 2009, 11:34:54 PM11/28/09
to
On Nov 28, 5:05 pm, Slava Pestov <sl...@jedit.org> wrote:
> On Nov 27, 10:31 pm, Hugh Aguilar <hugoagui...@rosycrew.com> wrote:
>
> > In Factor it is called DDUP.

> 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.

Andrew Haley

unread,
Nov 29, 2009, 4:10:14 AM11/29/09
to
Slava Pestov <sl...@jedit.org> wrote:

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.

Hugh Aguilar

unread,
Nov 29, 2009, 9:05:45 PM11/29/09
to
On Nov 29, 2:10 am, Andrew Haley <andre...@littlepinkcloud.invalid>
wrote:

> Slava Pestov <sl...@jedit.org> wrote:
> > 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.
>
> 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.

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.

Ian Osgood

unread,
Nov 30, 2009, 12:29:53 AM11/30/09
to

[ stuff ] dip

is pretty much equivalent to

>r stuff r>

in Forth. The secondary stack is a handy tool.

Ian

Aleksej Saushev

unread,
Dec 1, 2009, 5:51:14 AM12/1/09
to
Josh Grams <jo...@qualdan.com> writes:

> 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...

0 new messages