Path: utzoo!utgpu!watmath!att!rutgers!ucsd!usc!samsung!uunet!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.lang.forth Subject: Re: ANS FORTH/PICK and ROLL Message-ID: <6992@ficc.uu.net> Date: 16 Nov 89 13:00:22 GMT References: <8911152104.AA10027@jade.berkeley.edu> Reply-To: peter@ficc.uu.net (Peter da Silva) Organization: Xenix Support, FICC Lines: 65 In article <8911152104.AA10027@jade.berkeley.edu> Forth Interest Group International List writes: > LOCAL name ( initial-value -- ) So far, so good. > TO name ( value -- ) Bleaaaaagh!!!!!! NONONONONONO! Please please please. There is *no* technical reason to require this "TO" abomination. I experimented with this construct years ago, and decided that the extremely minor increase in clarity in a few cases was outweighed by (a) the lack of consistency... is that a constant or a variable... in the common case, and (b) the extra complexity in the case where you need an address. > Here's an example. Here's a changed version of your example using normal, conventional @ and !: : 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 @ - ( shouldn't this be <>??? ) WHILE addr @ 1 cells + 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 ; Actually, I'd do it like this: : search ( test start-addr size -- test next-addr size found-addr found? ) LOCAL size LOCAL start-addr LOCAL test size @ 0 do test @ i start-addr + @ @ = if i start-addr +! i size -! leave then loop size @ if test @ start-addr @ size + 0 0 0 else test @ addr @ 1 cells + size @ 1+ addr @ -1 then ; And let the optimiser worry about the details. -- `-_-' Peter da Silva . 'U` -------------- +1 713 274 5180. "*Real* wizards don't whine about how they paid their dues" -- Quentin Johnson quent@atanasoff.cs.iastate.edu