[plt-scheme] Side effect requiring rnrs/base-6?

From: Ganesh Gunasegaran (ganesh.gunas at gmail.com)
Date: Thu Sep 17 00:15:29 EDT 2009

Hi Jens,

Thanks for the explanation. Couple of questions

- The same code doesn't throw the mcar exception in Mac OSX version of  
DrScheme(4.2.1). The exception is thrown only in the linux version of  

- Even in the linux version of DrScheme, the exception is not thrown  
if I comment the unrelated letrec block.

Even if shadowing occurs as you suggested, there is inconsistency  
across operating systems.

Ganesh Gunasegaran.

#lang scheme
(require rnrs/base-6)

(letrec ([my-sum (lambda (l)
             (if (null? l)
                 (+ (car l) (my-sum (cdr l)))))])
  (my-sum '(1 2 3 4)))

(define my-sum
  (lambda (l)
    (if (null? l)
        (+ (car l) (my-sum (cdr l))))))

On 16-Sep-2009, at 11:29 PM, Jens Axel Søgaard wrote:

> 2009/9/16 Jens Axel Søgaard <jensaxel at soegaard.net>:
>> [sent privately too by accident]
>> 2009/9/16 Ganesh Gunasegaran <ganesh.gunas at gmail.com>:
>>> Hi All,
>>> I am very new to Scheme
>>> What is wrong with the following code?
>>> --------------------------------------------------------------------------------------------------------------------------------
>>> #lang scheme
>>> (require rnrs/base-6)
> One more thing:
> Since the entire rnrs/base-6 is required some functions from "scheme"
> such as car, cdr, cons are shadowed by their bindings in rnrs/base-6.
> In particular in rnrs the identifier car is bound to the same value
> as the identifier mcar is bound to in "scheme'. That is, after the
> require line, when you write "car" you are actually calling "mcar".
> This might we somewhat confusing, for new Scheme users, so
> here is a practical advise:
> Stick either to the "scheme" language, and if you need a particular
> function from rnrs use the documentation to figure out, what
> is called in PLT Scheme (in 99% of the cases the names
> are the same).
> -- 
> Jens Axel Søgaard

Posted on the users mailing list.