Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: Forth16e, Forth32e, "de facto" forth programming standards for embedded Date: Tue, 22 Jul 2014 03:47:31 -0400 Organization: Aioe.org NNTP Server Lines: 63 Message-ID: References: <49aa991d-41c6-44ae-afe4-ad1b7434011b@googlegroups.com> <62cc3792-e246-4f0b-b671-c09908d5f3b0@googlegroups.com> <9f8a7188-7ef0-4ae4-8341-e27a41f9a44b@googlegroups.com> <836283a2-64a1-4811-b653-13a099fbbb46@googlegroups.com> <0ade3c7c-d1c0-41f5-8f5e-055d66aaff6b@googlegroups.com> <53c928c6.819888433@news.demon.co.uk> <7xmwc69rdv.fsf@ruckus.brouhaha.com> <7xegxi9pzi.fsf@ruckus.brouhaha.com> <7edd6024-75fc-4c09-a7a9-892cd8b2c176@googlegroups.com> <0cedfdec-1922-4cc3-a339-2c5b292eb485@googlegroups.com> <26e2e926-3fd3-46a9-8876-42f1570795b6@googlegroups.com> <75a32142-6f65-4518-aa9d-3068bedd8899@googlegroups.com> NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:32535 On Tue, 22 Jul 2014 00:54:53 -0400, wrote: > On Monday, July 21, 2014 12:02:14 AM UTC-7, Elizabeth D. Rather wrote: >> Yes, DO loops and BEGIN loops are designed for completely different >> situations. That's why there are two families of iteration structures, >> each adapted for the appropriate case: >> >> DO ... LOOP structures are for "finite" loops, where you know how many >> times (or the maximum number of times) you want to do stuff. >> >> BEGIN ... WHILE/UNTIL structures are for "indefinite" loops, when how >> long you want to do it depends on unpredictable circumstances. >> >> Two sets of structures, optimized for two different situations. If you >> use DO ... LOOP structures when appropriate, I (and, occasionally, J) >> are very useful. If you start synthesizing these with BEGIN, etc., and >> locals, you'll be far less efficient. > > This is baloney. DO loops can be used for situations in which you don't > know how many times that you want to iterate. Yes, you can use both as an infinite loop that is escaped. You've demonstrated this below for DO. But, why would you use DO for an infinite loop when BEGIN generally has far less overhead? > For example, in my novice > package we have this for determining the length of a list: > > : length ( head -- count ) > 0 0 do > dup 0= if I nip unloop exit then > .fore @ loop ; > > If you do this with BEGIN, it will be less efficient because > of the stack-juggling needed. From my experience, DO I and LOOP use a large amount of return stack juggling using two stacked values. Are you taking into account the stack operations performed by the loop constructs DO I LOOP BEGIN AGAIN UNTIL ? Could you post the equivalent code using BEGIN AGAIN, preferably, or perhaps BEGIN UNTIL ? I might be coding it wrongly or differently in my head ... > DO loops really need to be trashed. Most high-level languages have counter based loops. What do you suggest instead? I.e., it still needs a counter, and needs to work with ANS, Forth 83, fig-Forth, etc. > I considered discarding >R etc., as they are also a throw-back > to the 1970s when Forth didn't have locals. With a few temporaries, you shouldn't really need locals either ... Yet, you want to discard one and implement the other. Odd. I'm sure I've mentioned this once or twice before too. You seem to repeat conversations as much or more than J.P. did. I just hope you're aware of that ... Rod Pemberton