[racket] Getting started with R6RS

From: Niklas Larsson (metaniklas at gmail.com)
Date: Sat May 14 07:35:47 EDT 2011

2011/5/14 Elliott Cable <me at ell.io>

> I’m new to both Racket and Scheme; I’ve been reading through the R6RS,
> and I’m trying to get started with some simple code.
>
> Unfortunately, I’m having trouble with Racket’s R6RS syntax/supporting
> features; what, exactly, is `(#%module-begin)` supposed to do? How am
> I supposed to properly use it? From the way I read it, I’m supposed to
> wrap every R6RS “library” and “top-level program” individually in a
> Racket `(#%module-begin)` to make Racket capable of understanding the
> R6RS content?
>
> Here’s what I was getting started with, and thus the code I can’t seem
> to get working. I get an error that it’s expecting an `(import)`
> instead of an `(export)`, which seems to me that it would source from
> Racket thinking it’s looking at an R6RS top-level program instead of a
> library (where `(export)` *would* be illegal syntax):
> https://gist.github.com/972114
>
> The error I’m getting is thus:
>
> some-r6rs.rkt:1:22: top-level-program: expected an `import'
> declaration, found something else in: (#%module-begin (library
> (wheeeee (1 1)) (export run) (import (library (rnrs base (6))))
> (define (run a) (printf "running!\n"))))
>
>
I don't think it's a great idea to start with R6RS, it has not gained a lot
of acceptance, so its advantages against the Racket language is mostly
theoretical.

That said, here's a simple R&RS program:

#!r6rs

(import (library (rnrs base (6)))
        (library (rnrs io simple (6))))

(display
 (+ 2 2))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110514/61220845/attachment.html>

Posted on the users mailing list.