Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!uwvax!rhesus!uwmacc!hobbes!circle From: David_Douthitt@circle.UUCP (David Douthitt) Newsgroups: comp.lang.forth Subject: Re: Forth and recursion Message-ID: <4.210890C6@circle.UUCP> Date: Sat, 25-Jul-87 03:19:54 EDT Article-I.D.: circle.4.210890C6 Posted: Sat Jul 25 03:19:54 1987 Date-Received: Sun, 26-Jul-87 02:18:28 EDT Organization: FidoNet node 121/1 - 1st Circle, Madison WI Lines: 24 There was an issue of Computer Language that described a recursive mechanism as follows (it was jun '85): : | SMUDGE ; IMMEDIATE : TORIAL DUP 1 = IF DUP * ELSE DUP 1- | TORIAL | * THEN ; : FAC TORIAL . ; I dont know why everyone takes such circuitous routes to recursion... in Mad Apple Forth, we have a word called MYSELF: : MYSELF LATEST 2+ 1 TRAVERSE 1+ , ; IMMEDIATE This would work very nicely for any recursion I might need... for example: : FACTORIAL DUP 1 = IF DUP * ELSE DUP 1- MYSELF * THEN ; It also is much more mnemonic than anything else I've seen to date. BTW, the definition of MYSELF assumes that LATEST returns the current (compiling) def's NFA (if memory serves) ... this is an indirect setup with nfas unlimited in size, but marked by hibits set at either end. Does this help? FidoNet: 121/1 UUCP: seismo!geowhiz!uwvax!hobbes!circle!david_douthitt "Curiouser and curiouser," said Alice.