[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: R5RS countdown



There are actually 2 bugs in the definition of OR in section 7.3.  The
following patch fixes both:

diff -c /home/jaffer/scheme/r5rs.ps\~ /home/jaffer/scheme/r5rs.ps
*** /home/jaffer/scheme/r5rs.ps~	Thu Feb 12 15:23:18 1998
--- /home/jaffer/scheme/r5rs.ps	Mon Feb 16 21:56:56 1998
***************
*** 12420,12427 ****
  (\(and)f(test2)g(...\))g(#f\)\)\)\))2090 3645 y(\(define-syntax)j(or)
  2169 3737 y(\(syntax-rules)f(\(\))2247 3828 y(\(\(or\))e(#f\))2247
  3919 y(\(\(or)g(test\))h(test\))2247 4011 y(\(\(or)f(test1)h(test2)f
! (...\))2286 4102 y(\(let)g(\(\(x)g(\(test1\)\)\))2365
! 4193 y(\(if)g(x)f(x)h(\(and)g(test2)g(...\)\)\)\)\)\))2090
  4438 y(\(define-syntax)j(let)2169 4529 y(\(syntax-rules)f(\(\))2247
  4620 y(\(\(let)e(\(\(name)h(val\))f(...\))g(body1)h(body2)f(...\))2286
  4711 y(\(\(lambda)h(\(name)g(...\))f(body1)g(body2)h(...\))2326
--- 12420,12427 ----
  (\(and)f(test2)g(...\))g(#f\)\)\)\))2090 3645 y(\(define-syntax)j(or)
  2169 3737 y(\(syntax-rules)f(\(\))2247 3828 y(\(\(or\))e(#f\))2247
  3919 y(\(\(or)g(test\))h(test\))2247 4011 y(\(\(or)f(test1)h(test2)f
! (...\))2286 4102 y(\(let)g(\(\(x)g(test1\)\))2365
! 4193 y(\(if)g(x)f(x)h(\(or)g(test2)g(...\)\)\)\)\)\))2090
  4438 y(\(define-syntax)j(let)2169 4529 y(\(syntax-rules)f(\(\))2247
  4620 y(\(\(let)e(\(\(name)h(val\))f(...\))g(body1)h(body2)f(...\))2286
  4711 y(\(\(lambda)h(\(name)g(...\))f(body1)g(body2)h(...\))2326

Diff finished at Mon Feb 16 21:57:53

			       -=-=-=-

Section 7.3 states:

 b(A)26 b(tric)n(k)e(is)h(used)f(to)h(generate)f(the)h(temp)r(o-)-300
 1483 y(rary)k(names)h(needed)h(to)f(a)n(v)n(oid)f(sp)r(ecifying)i(the)g
 (order)e(in)i(whic)n(h)-300 1583 y(the)e(v)-5 b(alues)27
 b(are)h(ev)-5 b(aluated.)38 b(This)28 b(could)g(also)f(b)r(e)i
 (accomplished)-300 1682 y(b)n(y)e(using)h(an)f(auxiliary)f(macro.)-143

 (define-syntax letrec
   (syntax-rules
    ()
    ((letrec ((var1 init1) ...) body ...)
     (letrec "generate temp names"
       (var1 ...)
       ()
       ((var1 init1) ...) body ...))
    ((letrec "generate temp names"
       ()
       (temp1 ...)
       ((var1 init1) ...)
       body ...)
     (let ((var1 <undefined>) ...)
       (let ((temp1 init1) ...)
	 (set! var1 temp1)
	 ... body ...)))
    ((letrec "generate temp names"
       (x y ...)
       (temp ...)
       ((var1 init1) ...) body ...)
     (letrec "generate temp names"
       (y ...)
       (newtemp temp ...)
       ((var1 init1) ...)
       body ...))))

This syntactic definition of letrec does not work because of the
"generate_temp_names" strings.  It is not obvious to me that R5RS
Macros are capable of generating unique temporary names, especially as
patterns in syntax rules.  Does R5RS somewhere give an example of
generating temporary names?  If not, this explanation is not
sufficient for some of R5RS's intended audience.

It took more than an hour for me to tease the Scheme code from the
postscript file.  It would greatly facilitate testing if you would
extract all the scheme code examples from r5rs.tex and post it to
rrrs-authors.