Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!CGEUGE54.BITNET!BARTHO From: BARTHO@CGEUGE54.BITNET (PAUL BARTHOLDI) Newsgroups: comp.lang.forth Subject: RE: New Directions: 'I' is broken in Forth Message-ID: <9001231641.AA14206@jade.berkeley.edu> Date: 23 Jan 90 08:15:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Forth Interest Group International List Organization: The Internet Lines: 72 >Let me say right now, that I am *not* proposing any of this for ANSI Forth. > ... >The problem, IMHO, with 'I' is that it is context sensitive, as in First, just a question not related to the subject: for us non americans, could you explain what is the meaning of IMHO or BTW ? we find in all messages now ... > > DO ... I ... DO ... I ... LOOP ... LOOP > >In this example, 'I' is not refering the same thing every place it >is mentioned. State-smart words are something else in Forth that >are potentially ambiguous, but at least they attempt to have the >same semantics. (There are arguments for/against state-smartness, >but I don't want to get sidetracked into that issue here.) I never found this a real problem, to the contrary. Where ever you are, you can use 'I' for the current loop index, irrespective of the other outer loops, and then 'J', 'K' etc for the next outer ones. >... >There would be, IMHO, two major gains by doing this. First, the >restrictions about using R>, >R before/during/after DO LOOPS would >be lifted. Second, the semantics of I J etc. would be simpler. >(Isn't forth's philosophy that simpler is better :-). >(The second one is what motivated this post, but the first one is just >as important, now that I consider it.) 100% right. The mess of confusing the return stack with loops and index is simply crazy, as is the use of the return stack for anything but return addresses. >I have seen reference to 'control stacks' (probably in Forth Dimensions, but >I can't recall) for solving this problem. Has anyone been using them or >are they just an acedemic exercise? and if 'yes', have control stacks >been found to introduce new problems? (Set aside 'efficiency', for the >moment, I mean semantic problems or difficulties). I never used >R or R> except when using some ones else programs. One of the first thing I did about 15 years ago starting with forth was to have a separate stack for the do-loops, and a little later to build into the 'basic' forth a stack structure that works like 'value' (or 'quant' ...). So when ever I need a stack I build one with nn STACK . Then I will push vales into that stack by ... INTO . pushes its top value onto the normal parameter stack (like a 'value') and the stack can be cleaned with RESET . Most of my programs have 2-4 such stacks for various uses (like redirecting i/o between screen, printer, ploter etc). An other advantage of the separate do-loops stack is that the indices can be used in any command call inside the do-loops. For example, you can have : .i I . cr ; then : x 10 0 do .i loop ; which i find quite useful. One important point to remember is that the do-loops stack MUST be cleared (resetting the pointers) when ever a command aborts. >I'm beginning to be of the opinion that DO LOOP and its use of the >return stack is not an elegant design, but rather one that was hacked >on top of the existing machinery. probably not hacked, but designed that way by Chuck Moore under very strong constraints for space. This is also in Chuck's style! >I am also beginning to be of the opinion that Forth is flexible enough to >allow you do 'do it right' and still be efficient. I agree with you, but talking about forth, what is 'right' ? (see also the discussion about a 'pure' postfix 'do' ...) regards, Paul Bartholdi, Geneva Observatory.