At 23 Jan 2018 15:57:34 -0500, "'John Clements' via Racket Users" wrote:
> despite being inside of a binding of the name map

That's the essence of the problem. Which things are in the scope of a
top-level definition?

For example, is the reference to `f` in the scope of a binding of `f`

  (define (g x) (f x))
  (define (f x) x)


How about in

    (define (g x) (f x))
    (define (f x) x))


Or in 

 (expand '(define (f x) x))
 (define (g x) (f x))


   (expand '(define (f x) x))
   (define (g x) (f x)))


The rule in Racket is that a top-level `define` doesn't change the
binding of an identifier until the `define` is evaluated. So, in

  (define (map x) ... map ...)

the reference to `map` is expanded/compiled at a point where `map`
refers to a module import, not a variable named `map`. By the time the
definition is evaluated, it's too late to redirect the meaning of `map`
as a reference to an import.

There are other choices, but I don't think there are going choices that
end up being significantly better or more consistent. The top level is

Modules behave significantly better, in part because the scope of a
definition is clear: from the start of the module to the end.

> When I try doing the same thing with a value defined in the empty program 
> (with the name’f’), I see the error 
> define-values: assignment disallowed;
>  cannot re-define a constant
>   constant: f
> Which leads me to the suspicion that maybe possibly this message is supposed 
> to be shown for the re-definition of ‘map’, as well?

The difference is that `f` starts out bound to the variable `f`, not to
an `f` import. For various reasons, we have decided that definitions
are allowed to shadow imports.

You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to