Deutsch   English   Français   Italiano  
<92920376458f20998b03b1cf7f400c9d@www.novabbs.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.misty.com!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: minforth@gmx.net (minforth)
Newsgroups: comp.lang.forth
Subject: Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]
Date: Wed, 11 Sep 2024 09:49:37 +0000
Organization: novaBBS
Message-ID: <92920376458f20998b03b1cf7f400c9d@www.novabbs.com>
References: <nnd$61e0ad9a$48ed61c2@b4d945e456041481> <vasqjd$icjm$1@dont-email.me> <aea5eb9efcc8f053ce5dd7ff60e9b808@www.novabbs.com> <nnd$14b31e9e$1edc4d58@02f458c65ed0f6f1>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
	logging-data="1647453"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="0+ejqm+s29REto3A2x2P4fP+XaUXf51pZgtYBR0nEqI";
User-Agent: Rocksolid Light
X-Rslight-Site: $2y$10$YyWkG3UkejvU0n/IdFNQ3.8hOPn9fqOA/qxiEPZsEtY7BB46Lvlha
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Posting-User: d2a19558f194e2f1f8393b8d9be9ef51734a4da3
Bytes: 2038
Lines: 20

On Wed, 11 Sep 2024 9:20:14 +0000, Hans Bezemer wrote:
> Tips:
> - Use multiple Return Stack registers (R@, R'@, R"@);
> - If parameters come in duplets or triplets, use corresponding stack
> operators (3DUP, 3OVER, 3DROP);
> - Reorganize parameters at the *very start* of the program in a more
> palatable order. It saves stack juggling later on;
> - Maybe a strange one, but codify stack patterns!
>    E.g. SPIN ( a b c -- c b a)
>         STOW ( a b -- a a b)
>         RISE ( a b c -- b a c)
>
> It helps you to THINK in these patterns and more easily recognize them.
> It depends highly on your coding habits, so it helps to analyze your
> legacy code to see if they often occur.

Good advice if you can access the return stack directly.

Otherwise, for non-trivial words, it is preferable to let the compiler
recognise patterns and save your precious human time. If the compiled
code is too bad, profile and optimise it afterwards.