On Sep 15, 2009, at 5:12 AM, Brian Mastenbrook wrote:

> I believe all such behavioral differences come down to the use of
> `define' at the top level to mean `set!'. If you always write `set!'
> when you mean to mutate an existing binding, you won't see a  
> difference.

I believe many people expect (or want) to have define=set! model
at the repl and many (other) people expect define to be a binding
construct at non-repl definitions.

Consider this very common (and probably incorrect) idiom:

(define +
   (let ([real-plus +])
     (lambda ---)))

Many expect real-plus to have the initial value bound to + (aka
#<primitive +> or whatever) and that + would later have the new
value.  This is set! that looks like define.

If define is considered a recursive binding construct whose scope
covers the expression at the right-hand-side, then that code is
obviously flawed since it's alpha-equivalent to:

(define +_0
   (let ([real-plus_1 +_0])
     (lambda ---)))

which triggers a runtime error due to reference to uninitialized
variable +_0.

I don't think people agree on most things when it comes to the
semantics of the repl.

Aziz,,,

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to