Subject: Re: Midfunction Recursion From: Erik Naggum <firstname.lastname@example.org> Date: 24 Oct 2002 14:42:43 +0000 Newsgroups: comp.lang.lisp Message-ID: <email@example.com> * Ray Blaak | Actually, there is no guarantee that assignment is necessarily being used | in the LOOP case (that is, in general -- it might well be in CL). | Consider that the particular loop could have been implemented as a macro | that expands into a local tail-recursive closure. The test for whether you have assignment or not is not found with the syntactic sugar. Try this in both Common Lisp and Scheme: (do ((i 1 (1+ i)) (foo () (cons (lambda () i) foo))) ((= i 5) foo)) If typed at the listener, you should now have a list of four closures in the variable *. Scheme victims may have to write more. (map apply *) yields (4 3 2 1), while (mapcar #'funcall *) yields (5 5 5 5). The reason for the dramatic difference should be intuitively evident. In fact, Common Lisp semantics is defined this way and Scheme semantics is defined that way, so it is not the option that Scheme freaks believe. | Ultimately its a non-issue if its "true" iteration vs tail recursion, | since they are semantically equivalent. No, they are not. The semantic distinction is precisely in the binding behavior of the variables. Scheme does not actually offer iteration. It annoys me that I know more about Scheme minutiae than Scheme freaks. -- Erik Naggum, Oslo, Norway Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.