Sujet : Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forthDate : 03. Sep 2024, 02:23:20
Autres entêtes
Organisation : Ausics - https://newsgroups.ausics.net
Message-ID : <66d66507$1@news.ausics.net>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 3/09/2024 2:03 am, Buzz McCool wrote:
On 8/30/24 13:32, minforth wrote:
use locals if you have too many parameters
I like this quite a bit. Tell me if I like it too much.
: CylVolLoop {: W: StartHeight W: FinalHeight F: Radius -- Tabular Output :}
cr ." Radius " Radius fe.
StartHeight
begin dup FinalHeight <=
while
dup
s>f
fdup
cr ." Height " fe.
Radius
VolOfCyl
." Volume " fe.
1 +
repeat
drop
cr ;
>
Under VFX Forth:
see CylVolLoop
...
( 193 bytes, 39 instructions )
\ Without locals...
: CylVolLoop ( StartHeight FinalHeight Radius -- )
cr ." Radius " fdup fe.
swap ( FinalHeight Height)
begin 2dup >= while
dup s>f fdup cr ." Height " fe.
fover ( Height Radius) VolOfCyl ." Volume " fe.
1+
repeat 2drop fdrop
cr ;
see CylVolLoop
...
( 148 bytes, 27 instructions )