Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #41981
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Strings and numbers |
| Date | 2015-09-13 00:12 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <87bnd6sshd.fsf@jester.gateway.pace.com> (permalink) |
| References | (8 earlier) <f8c62977-77d0-47ca-9f21-3c9589ec49a0@googlegroups.com> <87oah9st2o.fsf@jester.gateway.pace.com> <ec7d26f3-8d15-4e8d-a983-7e702b00e4e1@googlegroups.com> <7344e907-150a-4908-8fb3-7e5721796600@googlegroups.com> <c47ec179-6bfb-4713-bbad-173c42db7721@googlegroups.com> |
humptydumpty <ouatubi@gmail.com> writes:
> Is noteworthy that dynamically using variables, unlike using locals,
> permits factoring.
Yeah, I think the code I posted with the locals could have been arranged
to use the stack (maybe easier with 2 args instead of 3) but I didn't
feel up to the effort. Static variables of course don't work with
recursive functions where the locals need different values at different
call levels. I wrote some other recursive code a while back where I
didn't want to even think about how to get rid of the locals. Here you
do it by carefully modifying the global, using it, then unmodifying it
in order to backtrack. I think for the most part, the no-locals style
is harder for this sort of thing. But it's nice to see you and Richard
posting code without them.
> Just for factoring sake, under dynamically use of variable 'Bmp':
> : >{ ]] dup @ 2>R [[ ; IMMEDIATE
> : } ]] R> R> ! [[ ; IMMEDIATE
What are ]] and [[ ? They're not in the gforth manual word index.
> VARIABLE Bmp VARIABLE N
> DEFER run ( u -- )
What's the purpose of deferring run? I thought maybe it was for
mutually recursive functions but I didn't see anything that needed it.
> prologue
> 2dup N @ swap - mod 0=
> IF RECURSE THEN
> epilogue
I guess this uses less memory than leaving all that stuff on the stack
in the locals version.
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Strings and numbers Steve Graham <solitary.wanderer52@gmail.com> - 2015-08-03 13:24 -0700
Re: Strings and numbers Julian Fondren <julian.fondren@gmail.com> - 2015-08-03 13:51 -0700
Re: Strings and numbers "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-08-03 17:38 -0400
Re: Strings and numbers Steve Graham <solitary.wanderer52@gmail.com> - 2015-08-03 14:44 -0700
Re: Strings and numbers Paul Rubin <no.email@nospam.invalid> - 2015-08-03 20:59 -0700
Re: Strings and numbers Steve Graham <solitary.wanderer52@gmail.com> - 2015-08-04 12:19 -0700
Re: Strings and numbers "WJ" <w_a_x_man@yahoo.com> - 2015-08-07 09:29 +0000
Re: Strings and numbers "WJ" <w_a_x_man@yahoo.com> - 2015-09-04 15:14 +0000
Re: Strings and numbers "WJ" <w_a_x_man@yahoo.com> - 2015-09-07 19:34 +0000
Re: Strings and numbers Julian Fondren <julian.fondren@gmail.com> - 2015-09-08 11:48 -0700
Re: Strings and numbers Paul Rubin <no.email@nospam.invalid> - 2015-09-09 00:41 -0700
Re: Strings and numbers Richard Todd <richard.wesley.todd@gmail.com> - 2015-09-10 00:32 -0700
Re: Strings and numbers Richard Todd <richard.wesley.todd@gmail.com> - 2015-09-10 10:29 -0700
Re: Strings and numbers Paul Rubin <no.email@nospam.invalid> - 2015-09-10 17:22 -0700
Re: Strings and numbers Richard Todd <richard.wesley.todd@gmail.com> - 2015-09-10 21:34 -0700
Re: Strings and numbers humptydumpty <ouatubi@gmail.com> - 2015-09-11 02:16 -0700
Re: Strings and numbers humptydumpty <ouatubi@gmail.com> - 2015-09-11 07:33 -0700
Re: Strings and numbers Paul Rubin <no.email@nospam.invalid> - 2015-09-13 00:12 -0700
Re: Strings and numbers humptydumpty <ouatubi@gmail.com> - 2015-09-13 02:09 -0700
Re: Strings and numbers Paul Rubin <no.email@nospam.invalid> - 2015-09-11 15:53 -0700
Re: Strings and numbers Andrew Haley <andrew29@littlepinkcloud.invalid> - 2015-12-18 16:02 -0600
Re: Strings and numbers "WJ" <w_a_x_man@yahoo.com> - 2015-09-12 23:38 +0000
Re: Strings and numbers "WJ" <w_a_x_man@yahoo.com> - 2015-09-13 19:41 +0000
Re: Strings and numbers "WJ" <w_a_x_man@yahoo.com> - 2015-11-29 18:09 +0000
csiph-web