[plt-scheme] Side effect requiring rnrs/base-6?
That's quite a strange bug! It is also quite strange that commenting
out the letrec affects the behavior of the my-sum function.
Thanks for the report.
Robby
On Wed, Sep 16, 2009 at 11:33 PM, Ganesh Gunasegaran
<ganesh.gunas at gmail.com> wrote:
> Robby,
> Yes I am sure, I copy pasted the exact code. Here are the screenshots for
> your reference. You can also verify the version information in the
> interactive console.
> http://gallery.me.com/itsgg/100023/mac (No exception)
> http://gallery.me.c…/itsgg/100023/linux1 (Exception)
> http://gallery.me.c…/itsgg/100023/linux2 (Commented letrec block. No
> exception)
> Cheers,
> Ganesh Gunasegaran
> On 17-Sep-2009, at 9:54 AM, Robby Findler wrote:
>
> Are you sure you ran exactly the same code and you were using exactly
> the same version? At that level, there is no difference between the
> two versions (ie, it is the same source code that implements cons
> etc).
>
> Robby
>
> On Wed, Sep 16, 2009 at 11:15 PM, Ganesh Gunasegaran
> <ganesh.gunas at gmail.com> wrote:
>
> 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
>
> DrScheme(4.2.1).
>
> - 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.
>
> Cheers,
>
> Ganesh Gunasegaran.
>
> #lang scheme
>
> (require rnrs/base-6)
>
> (letrec ([my-sum (lambda (l)
>
> (if (null? l)
>
> 0
>
> (+ (car l) (my-sum (cdr l)))))])
>
> (my-sum '(1 2 3 4)))
>
> (define my-sum
>
> (lambda (l)
>
> (if (null? l)
>
> 0
>
> (+ (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
>
> _________________________________________________
>
> For list-related administrative tasks:
>
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
>