Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"Jesus may love you, but I think you're garbage wrapped in skin." -- Michael O'Donohugh


devel / comp.lang.forth / Re: convenient stack operation: a b c -- b a c

SubjectAuthor
* convenient stack operation: a b c -- b a cKrishna Myneni
+* Re: convenient stack operation: a b c -- b a cEric Griswold
|+- Re: convenient stack operation: a b c -- b a cKrishna Myneni
|`- Re: convenient stack operation: a b c -- b a cdxf
+* Re: convenient stack operation: a b c -- b a cmhx
|`- Re: convenient stack operation: a b c -- b a cKrishna Myneni
+- Re: convenient stack operation: a b c -- b a cminforth
+* Re: convenient stack operation: a b c -- b a cRon AARON
|`- Re: convenient stack operation: a b c -- b a cminforth
+* Re: convenient stack operation: a b c -- b a cnone
|`* Re: convenient stack operation: a b c -- b a cdxf
| `* Re: convenient stack operation: a b c -- b a cmhx
|  `- Re: convenient stack operation: a b c -- b a cHans Bezemer
`* Re: convenient stack operation: a b c -- b a cNN
 `- Re: convenient stack operation: a b c -- b a cKrishna Myneni

1
convenient stack operation: a b c -- b a c

<ukalqa$1fmfg$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25491&group=comp.lang.forth#25491

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: krishna.myneni@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: convenient stack operation: a b c -- b a c
Date: Thu, 30 Nov 2023 12:55:04 -0600
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <ukalqa$1fmfg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 30 Nov 2023 18:55:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b36cdd24889b46370144b7d2dbda3725";
logging-data="1563120"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WxMxfRwoXeDp8gpRYyVXB"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:uXh4BXzk29PRVW3TLCJq4lRb5+w=
Content-Language: en-US
 by: Krishna Myneni - Thu, 30 Nov 2023 18:55 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

>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

Re: convenient stack operation: a b c -- b a c

<86fs0nf0al.fsf@proton.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25492&group=comp.lang.forth#25492

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eric.griswold@proton.me (Eric Griswold)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Thu, 30 Nov 2023 12:34:10 -0800
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <86fs0nf0al.fsf@proton.me>
References: <ukalqa$1fmfg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="402610130245f2e03c3d0eec5eda3850";
logging-data="1594438"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/M8SqFqpVQckVSpaWPBjJA"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)
Cancel-Lock: sha1:tgQlH8IOwpZGbvpIpY5U00QtFRk=
sha1:/sbm8/rPSfbBTSHaycUvSeEE4zQ=
 by: Eric Griswold - Thu, 30 Nov 2023 20:34 UTC

Krishna Myneni <krishna.myneni@ccreweb.org> writes:

> 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

Speaking entirely as a wholly inexpert Forth aficionado, I like both the
name 'RISE' and function a lot.

Eric

Re: convenient stack operation: a b c -- b a c

<42503a031b0dd7fd817f809c0fdeb982@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25493&group=comp.lang.forth#25493

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!.POSTED!not-for-mail
From: mhx@iae.nl (mhx)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Thu, 30 Nov 2023 20:39:31 +0000
Organization: novaBBS
Message-ID: <42503a031b0dd7fd817f809c0fdeb982@news.novabbs.com>
References: <ukalqa$1fmfg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="2633645"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
X-Rslight-Site: $2y$10$I2/X2ACk77qfyFnRY5H4teRlvRZgPLvo9pEgd.8ZXMc7uawWEAvkW
X-Rslight-Posting-User: 463cbf1a76c808942982a163321348c75477c065
 by: mhx - Thu, 30 Nov 2023 20:39 UTC

In a corpus of about 8000 iForth files, "FROT FSWAP" appears 9 times:

Searching for: FROT FSWAP
D:dfwforthincludecomplex.frt(231): : X- FROT FSWAP F- <i1> <r1> <i2> <r2> --- <i3> <r3>
D:dfwforthincludecplx_fsl.frt(175): FROT FSWAP F- -FROT
D:dfwforthincludecplx_fsl.frt(210): FROT FSWAP FOVER F*
D:dfwforthincludefft.frt(66): : X- FROT FSWAP F- -FROT F- FSWAP ; PRIVATE
D:dfwforthincludemiscutil.frt(1761): FROT FSWAP F- -FROT F- FSWAP ;
D:dfwforthincludepcylfun.frt(259): FROT FSWAP FOVER F+
D:dfwforthincludepcylfun.frt(270): FROT FSWAP FOVER F+
D:dfwforthexamplesgraphicshenon.frt(71): y{ 0 1 :: }range[] FROT FSWAP SET-GWINDOW
D:dfwforthexamplesgraphicskrawczyk.frt(127): y{ 0 1 :: }range[] FROT FSWAP SET-GWINDOW

-marcel

Re: convenient stack operation: a b c -- b a c

<ukatrn$1h19k$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25494&group=comp.lang.forth#25494

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: krishna.myneni@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Thu, 30 Nov 2023 15:12:23 -0600
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <ukatrn$1h19k$1@dont-email.me>
References: <ukalqa$1fmfg$1@dont-email.me>
<42503a031b0dd7fd817f809c0fdeb982@news.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 30 Nov 2023 21:12:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b36cdd24889b46370144b7d2dbda3725";
logging-data="1606964"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/K+mhpqReXONwwsTmY24G7"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:Fl2NmOv+dbk4L8HN+BQC+n2He6I=
Content-Language: en-US
In-Reply-To: <42503a031b0dd7fd817f809c0fdeb982@news.novabbs.com>
 by: Krishna Myneni - Thu, 30 Nov 2023 21:12 UTC

On 11/30/23 14:39, mhx wrote:
> In a corpus of about 8000 iForth files, "FROT FSWAP" appears 9 times:
>
> Searching for: FROT FSWAP
> D:dfwforthincludecomplex.frt(231): : X- FROT FSWAP F-  <i1> <r1> <i2>
> <r2> --- <i3> <r3>
> D:dfwforthincludecplx_fsl.frt(175): FROT FSWAP F- -FROT
> D:dfwforthincludecplx_fsl.frt(210): FROT FSWAP FOVER F*
> D:dfwforthincludefft.frt(66): : X-    FROT FSWAP F- -FROT F- FSWAP ;
> PRIVATE
> D:dfwforthincludemiscutil.frt(1761): FROT FSWAP F- -FROT F- FSWAP ;
> D:dfwforthincludepcylfun.frt(259): FROT FSWAP FOVER F+
> D:dfwforthincludepcylfun.frt(270): FROT FSWAP FOVER F+
> D:dfwforthexamplesgraphicshenon.frt(71): y{ 0 1 :: }range[] FROT FSWAP
> SET-GWINDOW
> D:dfwforthexamplesgraphicskrawczyk.frt(127): y{ 0 1 :: }range[] FROT
> FSWAP SET-GWINDOW
>

That's not as many instances as I would have expected. I expect you
don't see it as much because you are probably using floating point locals?

--
Krishna

Re: convenient stack operation: a b c -- b a c

<ukauv4$1h7a6$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25496&group=comp.lang.forth#25496

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: krishna.myneni@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Thu, 30 Nov 2023 15:31:16 -0600
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <ukauv4$1h7a6$2@dont-email.me>
References: <ukalqa$1fmfg$1@dont-email.me> <86fs0nf0al.fsf@proton.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 30 Nov 2023 21:31:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b36cdd24889b46370144b7d2dbda3725";
logging-data="1613126"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KOP8gQqzlN48P9+wb9q1B"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:yvmoKS1T3yVrgs+oYR9v3MLz5H8=
In-Reply-To: <86fs0nf0al.fsf@proton.me>
Content-Language: en-US
 by: Krishna Myneni - Thu, 30 Nov 2023 21:31 UTC

On 11/30/23 14:34, Eric Griswold wrote:
> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>
>> 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
>
> Speaking entirely as a wholly inexpert Forth aficionado, I like both the
> name 'RISE' and function a lot.
>

It occurred to me after I posted the above, that maybe 0 RISE should do
nothing, 1 RISE should be the same as SWAP, etc. in order to correspond
to the meaning of RISE. The argument to rise is the depth of the element
relative to the top of the stack (TOS) which should move closer by 1
cell to TOS.

--
Krishna

Re: convenient stack operation: a b c -- b a c

<ukbamg$1ipev$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25497&group=comp.lang.forth#25497

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxforth@gmail.com (dxf)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Fri, 1 Dec 2023 11:51:28 +1100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ukbamg$1ipev$1@dont-email.me>
References: <ukalqa$1fmfg$1@dont-email.me> <86fs0nf0al.fsf@proton.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Dec 2023 00:51:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="750b3fa6e521252817d266d591063a89";
logging-data="1664479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pAtmb538qCXimepPrpa0X"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:whAbHT2dsfLR6zLJNdgBu1jEa9I=
Content-Language: en-GB
In-Reply-To: <86fs0nf0al.fsf@proton.me>
 by: dxf - Fri, 1 Dec 2023 00:51 UTC

On 1/12/2023 7:34 am, Eric Griswold wrote:
> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>
>> 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
>
> Speaking entirely as a wholly inexpert Forth aficionado, I like both the
> name 'RISE' and function a lot.

That would almost certainly give rise to accusations of 'stack juggling' :)

Re: convenient stack operation: a b c -- b a c

<0c70d0e9c7a156cff74057e380086427@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25498&group=comp.lang.forth#25498

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!.POSTED!not-for-mail
From: minforth@gmx.net (minforth)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Fri, 1 Dec 2023 01:53:18 +0000
Organization: novaBBS
Message-ID: <0c70d0e9c7a156cff74057e380086427@news.novabbs.com>
References: <ukalqa$1fmfg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="2657704"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Site: $2y$10$HxoOp0dz9XXX0AWOaWTvfux6wOIive/PVp4nlGeXwBpPeEg0z9pby
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
X-Rslight-Posting-User: 0d6d33dbe0e2e1ff58b82acfc1a8a32ac3b1cb72
 by: minforth - Fri, 1 Dec 2023 01:53 UTC

Krishna Myneni 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:
> 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 ).

In a 64-bit Forth, if the return stack does not allow it, you could
easily use the data stack to hold 64-bit fp numbers (a union in C parlance).
Otherwise I use F>R and FR> from time to time, or would use a scratch
FVARIABLE, or fp locals. Performance-wise, FROT FSWAP should be the fastest
for such a tiny task.

Re: convenient stack operation: a b c -- b a c

<ukc1du$1pjdt$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25499&group=comp.lang.forth#25499

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: clf@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Fri, 1 Dec 2023 09:19:26 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <ukc1du$1pjdt$1@dont-email.me>
References: <ukalqa$1fmfg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 1 Dec 2023 07:19:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c385f2d251c2fdf2419cab2efe965151";
logging-data="1887677"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1dP0K3V2bzoDnKQIOWu3s"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:DNSQQ1qAUxTnmAjRsAKJ43HadhA=
Content-Language: en-US, he
In-Reply-To: <ukalqa$1fmfg$1@dont-email.me>
 by: Ron AARON - Fri, 1 Dec 2023 07:19 UTC

On 30/11/2023 20:55, Krishna Myneni 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:
>
>    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
>

In 8th there's "_swap" which does "a b c -- b a c"

Re: convenient stack operation: a b c -- b a c

<6f40c7e434a4b3030e9438b4a240bfe8@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25500&group=comp.lang.forth#25500

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!.POSTED!not-for-mail
From: minforth@gmx.net (minforth)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Fri, 1 Dec 2023 08:26:25 +0000
Organization: novaBBS
Message-ID: <6f40c7e434a4b3030e9438b4a240bfe8@news.novabbs.com>
References: <ukalqa$1fmfg$1@dont-email.me> <ukc1du$1pjdt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="2684471"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
X-Rslight-Site: $2y$10$FazKdYDKGxmI4ZrnGakyHu7tgT7DQdUokHGzcwaIrngTyocW0By4G
X-Rslight-Posting-User: 0d6d33dbe0e2e1ff58b82acfc1a8a32ac3b1cb72
 by: minforth - Fri, 1 Dec 2023 08:26 UTC

Ron AARON wrote:
> In 8th there's "_swap" which does "a b c -- b a c"

With my ouput locals I could define it quickly by

: _SWAP { a b c == b a c } ;

or for fp numbers

: _FSWAP { f: a b c == b a c } ;

If used more often, a new primitive would be better.

Re: convenient stack operation: a b c -- b a c

<nnd$0a9a8826$1c6d9258@f70a1a3fc794ebcb>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25501&group=comp.lang.forth#25501

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
References: <ukalqa$1fmfg$1@dont-email.me>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$0a9a8826$1c6d9258@f70a1a3fc794ebcb>
Organization: KPN B.V.
Date: Fri, 01 Dec 2023 11:04:44 +0100
Path: i2pn2.org!i2pn.org!news.furie.org.uk!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe004.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 66
Injection-Date: Fri, 01 Dec 2023 11:04:44 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: none - Fri, 1 Dec 2023 10:04 UTC

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:
>
> 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?

It is insane. I'm reading through your programs and I
encounter SWAP-UNDER .
It involves stack operations, so there is no way you
can understand the code unless you have looked up
this words.

Remember the washing machine example of Brodie?
All stack manipulations are hidden.
The program proceeds with normal words that describe
the actions that are done.

You already have three items on the stack, that is
too much. Unless it is actally a double item,
say a string, and a single item.

>--
>Krishna Myneni

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: convenient stack operation: a b c -- b a c

<ukdubj$22ohh$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25505&group=comp.lang.forth#25505

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxforth@gmail.com (dxf)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Sat, 2 Dec 2023 11:39:15 +1100
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <ukdubj$22ohh$1@dont-email.me>
References: <ukalqa$1fmfg$1@dont-email.me>
<nnd$0a9a8826$1c6d9258@f70a1a3fc794ebcb>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 2 Dec 2023 00:39:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ba63cca51d96737b2f8f95151e798bcb";
logging-data="2187825"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kwn6Hg+zh7POUcZC0PfDc"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8GWD08KThsiRVHfW2SDmUsSzeKM=
Content-Language: en-GB
In-Reply-To: <nnd$0a9a8826$1c6d9258@f70a1a3fc794ebcb>
 by: dxf - Sat, 2 Dec 2023 00:39 UTC

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:
>>
>> 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.
>
> [...]
> I'm reading through your programs and I encounter SWAP-UNDER .
> It involves stack operations, so there is no way you
> can understand the code unless you have looked up
> this words.

Looking at various sources, including my own, ROT SWAP is not a common
sequence. Indeed, I would say it is exceptional. Scanning SwiftForth
sources and libs it is used once. In my case it was a setup for CMOVE
which I used on a couple occasions:

( dest src len) <process-source>
( dest src' len') ROT SWAP CMOVE ( save result)

I could have written:

( src len dst) >R <process-source>
( src' len') R> SWAP CMOVE ( save result)

but it would have been costlier. So I've no regrets.
> Remember the washing machine example of Brodie?
> All stack manipulations are hidden.
> The program proceeds with normal words that describe
> the actions that are done.

If you mean factoring as a way of improving readability and hiding
'noise words', yes. But we're told define words used only once is
a 'waste' of namespace. This may be a learned response. If one
sees an algorithm written in C in one chunk, the temptation is to
duplicate that.

> You already have three items on the stack, that is
> too much. Unless it is actally a double item,
> say a string, and a single item.

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.

Re: convenient stack operation: a b c -- b a c

<6f8247a809bb052b2a2400c87c73f7be@www.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26681&group=comp.lang.forth#26681

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!.POSTED!not-for-mail
From: mhx@iae.nl (mhx)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Sun, 14 Apr 2024 15:23:52 +0000
Organization: novaBBS
Message-ID: <6f8247a809bb052b2a2400c87c73f7be@www.novabbs.com>
References: <ukalqa$1fmfg$1@dont-email.me> <nnd$0a9a8826$1c6d9258@f70a1a3fc794ebcb> <ukdubj$22ohh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1164006"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Posting-User: 59549e76d0c3560fb37b97f0b9407a8c14054f24
X-Rslight-Site: $2y$10$dS2skT7Bc5dlB5WtV.4OHuMDJ2AtPcmtQFy63nWy1wKtK3b13/TUq
 by: mhx - Sun, 14 Apr 2024 15:23 UTC

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

Re: convenient stack operation: a b c -- b a c

<nnd$1fe73687$71d49db9@84f3e221daf0e086>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26749&group=comp.lang.forth#26749

  copy link   Newsgroups: comp.lang.forth
Date: Sun, 21 Apr 2024 15:51:18 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: convenient stack operation: a b c -- b a c
Newsgroups: comp.lang.forth
References: <ukalqa$1fmfg$1@dont-email.me>
<nnd$0a9a8826$1c6d9258@f70a1a3fc794ebcb> <ukdubj$22ohh$1@dont-email.me>
<6f8247a809bb052b2a2400c87c73f7be@www.novabbs.com>
Content-Language: en-US
From: the.beez.speaks@gmail.com (Hans Bezemer)
In-Reply-To: <6f8247a809bb052b2a2400c87c73f7be@www.novabbs.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$1fe73687$71d49db9@84f3e221daf0e086>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe004.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 22
Injection-Date: Sun, 21 Apr 2024 15:51:18 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Hans Bezemer - Sun, 21 Apr 2024 13:51 UTC

On 14-04-2024 17:23, mhx wrote:
> 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).

Same thing here -even lower- about 20 times in 900 files. Curiously, 25%
of them as a part of "-rot swap". With that frequency, I see little use
of adding a word like "RISE". As a metaphor for certain stack
operations, I don't think it's very compelling.

I mean - a stack operator is like telling a story:
- drop the 2OS item;
- duplicate 2OS to 2OS;
- duplicate TOS to 3OS;
- swap 3OS with TOS.

I can all easily imagine uses for that. "SWAP 3OS with 2OS" isn't
telling me such a story. Sorry.

Hans Bezemer

Re: convenient stack operation: a b c -- b a c

<v15jc0$18s7o$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26941&group=comp.lang.forth#26941

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: november.nihal@gmail.com (NN)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Sat, 4 May 2024 16:14:08 +0100
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <v15jc0$18s7o$2@dont-email.me>
References: <ukalqa$1fmfg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 04 May 2024 17:14:09 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="eeb3138f11df8b7a4d868450d89192bf";
logging-data="1339640"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nr069QHPo7MG/fMG+cLIP"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hm+HrxjInhLlE/bSFfbrXSeIg9E=
In-Reply-To: <ukalqa$1fmfg$1@dont-email.me>
Content-Language: en-US
 by: NN - Sat, 4 May 2024 15:14 UTC

On 30/11/2023 6:55 pm, Krishna Myneni 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:
>
>    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
>

Since no one suggested it, in factor they have called it swapd ( x y z
-- y x z )

https://docs.factorcode.org/content/word-swapd%2Ckernel.html

Using the same convention you could call it fswapd for operating on the
floating stack.

Re: convenient stack operation: a b c -- b a c

<v15qc7$1afff$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26944&group=comp.lang.forth#26944

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: krishna.myneni@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: convenient stack operation: a b c -- b a c
Date: Sat, 4 May 2024 12:13:43 -0500
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <v15qc7$1afff$1@dont-email.me>
References: <ukalqa$1fmfg$1@dont-email.me> <v15jc0$18s7o$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 04 May 2024 19:13:43 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d9cb9fe2f53d96b09e71dbfd93275420";
logging-data="1392111"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Wr9/RiTg81KhOJJ7CB2HN"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:dic90YOVyAud1MiMGyXrByoObR0=
Content-Language: en-US
In-Reply-To: <v15jc0$18s7o$2@dont-email.me>
 by: Krishna Myneni - Sat, 4 May 2024 17:13 UTC

On 5/4/24 10:14, NN wrote:
> On 30/11/2023 6:55 pm, Krishna Myneni 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:
>>
>>     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
>>
>
>
> Since no one suggested it, in factor they have called it swapd ( x y z
> -- y x z )
>
> https://docs.factorcode.org/content/word-swapd%2Ckernel.html
>
> Using the same convention you could call it fswapd for operating on the
> floating stack.

Thanks for the suggestion. It's nice to have a word name with some
history of use.

--
KM

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor