[racket] internal definitions in r6rs

From: Jos Koot (jos.koot at telefonica.net)
Date: Sat Sep 18 06:52:26 EDT 2010

Section 11.3 of R6RS states: "An expanded <body> (see chapter 10) containing
variable definitions can always be converted into an equivalent letrec*
expression." The semantics of letrec* includes "each <variable> is assigned
in left-to-right order". This I interpret as allowing an internal definition
to refer to the value of a previously defined variable. However:
 (rnrs base (6))
 (rnrs io simple (6)))
(define (a)
  (define (b) "who cares?")
  (define c (b))
(write (a))
Welcome to DrRacket, version [3m].
Language: r6rs; memory limit: 2000 MB.
. . procedure application: expected procedure, given: #<undefined> (no
The code expands as follows. The hot spots is marked with an arrow.
(module anonymous-module r6rs
   (#%require r6rs/private/prelims)
   (#%require (lib "rnrs/base-6.rkt"))
   (#%require (for-meta #f (lib "rnrs/base-6.rkt")))
   (#%require (lib "rnrs/io/simple-6.rkt"))
   (#%require (for-meta #f (lib "rnrs/io/simple-6.rkt")))
   (define-values (a)
      (let-values (((b) undefined) ((c) undefined))
        (let-values ; <====== prohibits reference to value of previously
defined var
              (#%plain-lambda () (letrec-values () (let-values () '"who
             ((newtemp:19) (#%app b))) ; <======
          (set! b newtemp)
          (set! c newtemp:19)
          (let-values:20 () (let-values:21 () c))))))
   (#%app write (#%app a))))

Is this a bug or do I misunderstand R6RS?
The following works correct:
 (rnrs base (6))
 (rnrs io simple (6)))
(define (a)
   ((b (lambda () "who cares?"))
    (c (b)))
(write (a))
Thanks, Jos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100918/22af50ed/attachment.html>

Posted on the users mailing list.