[racket] Running Racket in the R6RS mode

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Jul 14 08:58:29 EDT 2012

This simple question requires a non-trivial answer. 

The bottom line is "commit to the language that you 
think is stable, rich enough in terms of libraries, 
has a helpful user community, and so on". 

The justification is quite long. 

As much as you might wish to port Scheme programs, this 
just isn't possible without committing to some uncertainty
and/or a much more restricted programming style than you 
think you need. For example, the Scheme standard does not
commit to an order of evaluation in applications. So, even
a functional expressions (no set! etc) such as 

 (f Exp1 Exp2 Exp3) 

does not guarantee what kind of arithmetic exception you get
if something should happen deep in the guts of one of the three

For one way to find the right portability, see Dorai Sitaram's
article in the Boston Scheme workshop from 7 or 8 years ago. In
the end, he basically defines a new language and supplies macros
that expand it properly into each dialect plus Common Lisp. The 
latter may surprise you but portability among Schemes back then 
was so bad that throwing in CL wasn't a big deal. 

Next, while r6rs gives you a decent amount of modularity and
libraries, you will need to write your program so that it 
prints its results and reads its inputs. Relying on the 
implementation-provided read-eval-print loop and its read
and printing style probably won't do it. In your example
below, you are running into this already. 

BUT, when you have to go beyond the rather small language 
of r6rs -- do not let people distract you who think it is 
large -- you are facing the final problem, namely, how to 
pull in libraries for the real uses of a language: GUIs, 
portable GUIs, scientific libraries, or arbitrary code 
repositories with contributions from the community. Last
but not least the syntax system of each r6rs is rich enough
to tempt you into non-portability and then you're totally 

It is for all these reasons that we decided to forgo 
Scheme-ness and turn Racket into an independent member 
of the Lisp family with inspiration taken from some of 
the Scheme reports. 

Racket's goal is to help programmers [1] produce programs 
quickly -- with rich libraries -- easily portable from 
machine to machine -- because of a platform independent 
GUI library -- and to lend a helping hand as quickly as 
possibly -- with a highly responsive user mailing list. 

-- Matthias

[1] Knowing existing Scheme and Lisp idioms makes life
easy, nothing familiar has a radically different semantics. 
But knowing these languages is not a prerequisite. 

On Jul 14, 2012, at 12:51 AM, Rouben Rostamian wrote:

> Here is the entire contents of a file named tryme.rkt:
> ;;-----------------------------
> #!r6rs
> (import (rnrs base)
>        (rnrs sorting (6)))
> ;;-----------------------------
> I start up racket from the command-line (non-gui) and type:
> (enter! "tryme.rkt")
> (list-sort < '(4 2 7 1))  ; note: list-sort is from R6RS's sorting library
> This produces:
>     (mcons 1 (mcons 2 (mcons 4 (mcons 7 '()))))
> Is there a way to get a plain (1 2 4 7) representation?
> Aside: My objective here is to limit Racket to R6RS in the
> hope that my code will be portable to other platforms that
> implement R6RS.  If this is not the right way of going
> about it, please let me know
> -- 
> Rouben Rostamian
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Posted on the users mailing list.