Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!MITCH.ENG.SUN.COM!wmb From: wmb@MITCH.ENG.SUN.COM Newsgroups: comp.lang.forth Subject: Re: Use explicit arguments Message-ID: <9102050318.AA12062@ucbvax.Berkeley.EDU> Date: 5 Feb 91 02:15:49 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: wmb%MITCH.ENG.SUN.COM@SCFVM.GSFC.NASA.GOV Organization: The Internet Lines: 34 > : DOTS ( a \ n -- ) FOR @+ . NEXT DROP ; > > instead of any of: > > : DOTS ( a \ n -- ) 0 ?DO DUP @ . CELL + LOOP ; > : DOTS ( a \ n -- ) 0 ?DO DUP I CELL * + @ . LOOP ; > : DOTS ( a \ n -- ) CELL * OVER + SWAP ?DO I @ . CELL +LOOP ; How about: : DOTS ( a \ n -- ) 0 ?DO @+ . LOOP DROP ; It should be easy for the compiler to figure out that it can do the optimization. Chuck wasted a lot of people's time when he introduced a new function to handle a special case of an existing construct, rather than make his compiler a little smarter. The compiler optimization would have made everybody's existing code run faster, rather than making everybody rewrite their code, which then would be incompatible with systems without FOR .. NEXT . Admittedly, DO .. LOOP is a bit of a crock, but it is a crock with a lot of history behind it, and it does in fact work. > I assume the stack diagram for @+ ( a -- a+ \ n ). These incrementing fetch > words are some of the newer "ideas" injected into the Forth domain by Chuck. > He's had a chance to see what Forth really looks like in hardware. Of course, C has had autoincrementing pointers for 20 years. In Forth, a new idea is when Chuck reinvents or finally decides to use something that has been around since the dawn of time. Then everybody decides that, if Chuck says it, it must be right. Mitch Bradley, wmb@Eng.Sun.COM