Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: jacko Newsgroups: comp.lang.forth Subject: Re: In Forth, is it valid or safe to use the value of 'I' after LOOP? Date: Thu, 15 Mar 2012 19:09:12 -0700 (PDT) Organization: http://groups.google.com Lines: 49 Message-ID: <18438112.345.1331863752069.JavaMail.geo-discussion-forums@vbas10> References: <1KGdnU2taaxgpMjSnZ2dnUVZ_hGdnZ2d@supernews.com> NNTP-Posting-Host: 92.40.254.185 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1331863752 32497 127.0.0.1 (16 Mar 2012 02:09:12 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 16 Mar 2012 02:09:12 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=92.40.254.185; posting-account=kZanLQoAAABvNhBbAlX1SsCxeprjdiHJ User-Agent: G2/1.0 Xref: csiph.com comp.lang.forth:10146 On Tuesday, March 6, 2012 11:20:36 PM UTC, Rod Pemberton wrote: > "Elizabeth D. Rather" wrote in message > news:MMGdnUxDfcbF_cvSnZ2dnUVZ_s6dnZ2d@supernews.com... > > On 3/6/12 8:33 AM, Rod Pemberton wrote: > > >> "Elizabeth D. Rather" wrote in message > > > news:1KGdnU2taaxgpMjSnZ2dnUVZ_hGdnZ2d@supernews.com... > > >>> On 3/5/12 11:23 AM, Rod Pemberton wrote: > > > [...] > > > > > >> I isn't a "variable" it's a word that pushes a *copy* of the current > > >> value of the loop counter onto the stack when it is executed. Once on > > >> the stack, it's like any other stack item, to use as you see fit. > > > > > > Yes, I noticed that ... It seems that that also restricts the use of > > > 'I' to do "skip counters" too. [...] It seems one would need to setup > > > a separate variable in Forth to perform the skip. > > > > If you need to manipulate the loop index, it's easy to do it with +LOOP. > > That's what it's for. > > > > You don't find this mechanism clumsy or obtuse or awkward? > > First, let us hide the loop counter behind a word that fetches it so no one > can modify the counter directly. Next, let's create another word that is > used to add values to the counter since we no longer allow direct access to > the counter. Now, let's create another word so we can add some other value > besides one to it, or well define LOOP in terms of +LOOP ... Ah, only 3 > words to access the index. That's clearly insufficient! Oh, let's create J > and K too, since implementing I by itself wasn't difficult enough. Three > loop counters should do it. Also, let's require DO to initialize I, J, and > K before we indicate which one we are going to use. Now, that's a > challenge! And, let's make it so J and K can only be used in nested DO > LOOPS, respectively. Now is DO hard enough for us to implement? Ah, now 6 > we've dedicated words to do what Forth can do with a variable and three > generic words. We're definately on the "right" track with this looping > thing guys! Oh, we forgot a way to exit the loop: LEAVE. The Forth looping > mechanism *almost* seems perverse to me. But, hey, the cashier at McDonald's > basically threw my money out the window and let the wind blow it away. So, > maybe I'm just cranky today. If she stuffed it in her pocket, she'd be a > thief! I didn't get my money. Isn't that the same? Since I didn't get it > and was owed it, can I claim they stole it? That's the definition of > stealing ... right? Or, is shoving your hand out the window and letting go > in the wind adequate and sufficient to comply with not "stealing" ones > money? Insanity, just like I J K DO LOOP +LOOP /LOOP -LOOP LEAVE ... > When does it end? RfC for X Y Z *LOOP fibLOOP \LOOP :LOOP ;LOOP > ?LOOP aLOOP bLOOP anyone? 'I @ .