Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!SUN.COM!wmb From: wmb@SUN.COM (Mitch Bradley) Newsgroups: comp.lang.forth Subject: Re: ANS FORTH/PICK and ROLL Message-ID: <8911152104.AA10027@jade.berkeley.edu> Date: 15 Nov 89 19:24:11 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Forth Interest Group International List Organization: The Internet Lines: 58 > How WOULD you get along without [PICK and ROLL] I get along without ROLL just fine. I can't remember the last time I used it. The only thing I would miss is "2 PICK". Like the article in Forth Dimensions says, you can always implement PICK and ROLL in high level if you have to. You need not worry, because most vendors are going to implement the full core extension wordset anyway, for marketing reasons. The "required/extension" separation is really a political technique used to facilitate compromise between standards team members. For some words, there is a "must have it" camp and a "no way, I don't want to burden my system with that useless word" camp. Such words often end up in the extension part of a wordset. The need for PICK is somewhat reduced by the existence of local variables. At the last meeting, a proposal for local variables was adopted. Here is how it works: LOCAL name ( initial-value -- ) Used inside a colon definition to define a local variable. When the colon definition is executed, the stack is popped into the local variable. When name is later used within that definition, the value is left on the stack. TO name ( value -- ) Changes the value of a local variable. Here's an example. This word looks for the first occurrence of the value "test" between start-addr and start-addr + size . It illustrates the use of LOCAL/TO and multiple WHILEs . I have used capitalization to point out new usage. : search ( test start-addr size -- test next-addr size found-addr found? ) swap LOCAL addr ( test size ) addr + LOCAL end-addr ( test ) LOCAL test BEGIN addr end-addr < WHILE addr @ test - WHILE addr 1 cells + TO addr AGAIN THEN THEN \ resolve both "while"s \ REPEAT THEN would have worked too addr end-addr < if test addr 1 cells + end-addr addr - addr -1 else test end-addr 0 0 0 then ;