Re: Use of PICK and ROLL
- From: Elizabeth D Rather <eratherXXX@xxxxxxxxx>
- Date: Wed, 14 Mar 2007 09:18:36 -1000
duke wrote:
On Mar 13, 10:30 pm, "Ed" <nos...@xxxxxxxxxxx> wrote:"duke" <dnorman...@xxxxxxxxxxxxxxxxxxxxx> wrote in messagenews:1173632732.451317.120600@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHey....PICK and ROLL are in the ANS CORE-EXT wordset and thus
First, thanks to all who replied concerning the appropriateness of
newbie questions on this newsgroup.
In Leo Wong's tutorial "Simple Forth" it states:
"Forth programmers generally don't use PICK and ROLL much, preferring
specific to general solutions, and avoiding the temptation to treat
the stack as array"
Other than suspecting that PICK and ROLL are not supported by every
"flavor" of Forth, I don't understand where the issue is. Could
someone please flesh out the above quotation for me, so that I can see
the issue? I *do not* question that there is an issue -- I simply
can't see it for looking. TIA...
virtually all forths of reasonable size support them.
Sadly PICK and ROLL have become Forth's "bogey men". It's
undeserved. Like any tool, it's a case of when and how it's used.
High usage of PICK or ROLL may indicate too many items on
the stack, in which case one should re-think the problem.
OTOH, one may encounter stack arguments/results that are lengthy
or complicated but cannot be changed e.g. a Windows API call.
In such cases PICK and ROLL can be useful in dealing with them.
Contrary to some claims, PICK as an operator is very efficient.
So for the benefit of this Forth newbie, would it be fair to summarize
the responses to this thread as follows:
1. Factor each "word" as much as possible within practical limits
2. use PICK very sparingly, and *only after* #1 has been achieved
3. Refrain from using ROLL as much as possible, *if ever*
Pretty close. PICK can be used sparingly, with low numbers (2, 3 maybe). Forget ROLL. In doing your factoring, look for components that (a) can be re-used; or (b) will make testing easier (e.g. insides of loops).
Cheers,
Elizabeth
--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310-491-3356
5155 W. Rosecrans Ave. #1018 Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
==================================================
.
- Follow-Ups:
- Re: Use of PICK and ROLL
- From: Ron Aaron
- Re: Use of PICK and ROLL
- From: Bruce McFarling
- Re: Use of PICK and ROLL
- References:
- Use of PICK and ROLL
- From: duke
- Re: Use of PICK and ROLL
- From: Ed
- Re: Use of PICK and ROLL
- From: duke
- Use of PICK and ROLL
- Prev by Date: Re: Use of PICK and ROLL
- Next by Date: Re: Use of PICK and ROLL
- Previous by thread: Re: Use of PICK and ROLL
- Next by thread: Re: Use of PICK and ROLL
- Index(es):
Relevant Pages
|
Loading