Re: [racket-users] let/define

2015-11-03 Thread Neil Van Dyke
Holdouts who never adopted the new-fangled internal `define` still find `begin`'s semantics to be quite simple and intuitive. :) I suspect that people like internal `define` because it looks simpler than `let`. However, if simplicity is one's motivation for teaching internal `define` rather

Re: [racket-users] let/define

2015-11-03 Thread Éric Tanter
The naive model for begin is to think of it as a function that returns its last argument (assuming left-to-right evaluation). So that doesn’t scale. The example without begin you mention indeed behaves the same, and that follows from the model of “let has an implicit begin” that I tell them abo

Re: [racket-users] let/define

2015-11-03 Thread Scott Moore
I think its more a complexity of “define” than of “begin” (though begin is certainly tricky be because it can introduce and internal definition context). Your student’s program has the same behavior as this program without the begin, since the let also introduces a definition context: (let ([y

Re: [racket-users] let/define

2015-11-03 Thread Éric Tanter
Thanks all! This is helpful — the mental model of begin that I presented to my students was too simple to account for defines. -- Éric > On Nov 2, 2015, at 10:00 PM, Scott Moore wrote: > > The relevant part of the reference for these “internal definition contexts” > is here: > http://docs.r

Re: [racket-users] let/define

2015-11-02 Thread Robby Findler
Yeah, perhaps I've drunk too much of the koolaid, but I'm not even seeing an alternative interpretation that makes any sense! Does it help to see the arrows in DrRacket? In particular the upward pointing one that points at the 'y' in display's argument? Robby On Mon, Nov 2, 2015 at 6:32 PM, Ale

Re: [racket-users] let/define

2015-11-02 Thread Alex Knauth
This is because begin can have potentially recursive and mutually recursive definitions in it. This does the same thing: (let ([y 5]) (local [(define x y) ; this y should be bound to (define y 10)] ; <- this y, but it is used too early y)) While this slightly different case wor

[racket-users] let/define

2015-11-02 Thread Éric Tanter
Hi all, Some of my creative students came up with the following: (let ([y 5]) (begin (display y) (define y 10) y))) which raises a mysterious y: undefined; cannot use before initialization I remember earlier discussion on this list about the fact that `define' was somehow “broken” f