[racket] internal definitions in r6rs

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

 
Thanks.
I do not often use rnrs, for I prefer racket. But sometimes people ask me
r6rs or even r5rs code. I have decided to send them racket code and let them
make the required mods themselvesw.
Thanks, Jos

> -----Original Message-----
> From: robby.findler at gmail.com 
> [mailto:robby.findler at gmail.com] On Behalf Of Robby Findler
> Sent: 19 September 2010 01:03
> To: Jos Koot
> Cc: PLT-Scheme Mailing List
> Subject: Re: [racket] internal definitions in r6rs
> 
> It has been a while but I believe the r6 formal model covers 
> this point.
> 
> Robby
> 
> On Saturday, September 18, 2010, Jos Koot 
> <jos.koot at telefonica.net> wrote:
> >
> >
> >
> >
> >
> > Hi,
> >
> > 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:
> >
> > #!r6rs
> >
> > (import
> >  (rnrs base (6))
> >  (rnrs io
> > simple (6)))
> >
> > (define
> > (a)
> >   (define (b) "who cares?")
> >   (define c (b))
> > c)
> >
> > (write
> > (a))
> >
> > Produces:
> >
> > Welcome to
> > DrRacket, version
> > 5.0.1.5--2010-09-13(5b54caebb066920e2585244a5ee444a3f121c966/a)
> > [3m].
> > Language: r6rs; memory limit: 2000 MB.
> > . . procedure application:
> > expected procedure, given: #<undefined> (no arguments)
> >
> > The code
> > expands as follows. The hot spots is marked with an arrow.
> >
> > (module
> > anonymous-module r6rs
> >   (#%plain-module-begin
> >    (#%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)
> > (#%plain-lambda
> > ()
> >       (let-values (((b) undefined) ((c)
> > undefined))
> >         (let-values ;
> > <====== prohibits reference to value of previously defined var
> > (((newtemp)
> > (#%plain-lambda () (letrec-values () (let-values () '"who
> > cares?"))))
> > ((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:
> >
> > #!r6rs
> >
> > (import
> >  (rnrs base
> > (6))
> >  (rnrs io simple (6)))
> >
> > (define (a)
> > (letrec*
> >    ((b (lambda () "who cares?"))
> >     (c
> > (b)))
> >    c))
> >
> > (write (a))
> >
> > Thanks,
> > Jos
> >
> >
> >




Posted on the users mailing list.