Aaron W. Hsu wrote: > This is true in general, but I think the assertion was that two > procedures that do not need closures to run correctly, can only be > observationally different or distinct if they have different code bodies. > I am not seeing a fault in this reasoning off the top of my head.
You are speaking as though whether a procedure needs a closure to run correctly is a simple binary choice. It is not. The following example is almost exactly the same as the example I gave in my post of 9 May: (define (f m n) (define (g i) (define (h j) (if (= j 0) i (g (- j 1)))) (if (< i 0) (if (= i m) h ; must a closure be allocated here? #f) (h (- i 1)))) (g n)) With the R6RS semantics, a compiler is allowed to rewrite the escaping reference to h as (lambda (j) (h j)), which means the closure will be allocated only if i<0 and i=m. With that rewrite, f allocates no storage at all if its second argument is non-negative. With the R6RS semantics, most calls to f are unlikely to need closures, yet the code vector alone is inadequate to distinguish proc1 and proc2 defined via (define proc1 (f -1 -1)) (define proc2 (f -2 -2)) With the R5RS semantics, closures (or unique tags, which are almost as expensive as closures) will probably have to be allocated for every call to f and for every internal call to g. Since most calls to g occur within a tight loop, creating and garbage-collecting those closures or unique tags is likely to dominate the running time. That's a high price to pay for a theoretically inelegant misfeature that's seldom used correctly in portable code. Will _______________________________________________ r6rs-discuss mailing list r6rs-discuss@lists.r6rs.org http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss