I forgot to add one rationale for having a context dependent meaning of define-values. With the current setup, you can write
(module foo some-lang (define (range ...) ...)) without worrying about whether range is defined in some-lang or not. -- Jens Axel Søgaard 2012/10/23 Jens Axel Søgaard <jensa...@soegaard.net>: > 2012/10/23 Dan Grossman <d...@cs.washington.edu>: >> >> Thanks, David. I would be interested in someone walking through how this >> behavior arises -- as well as the design issue regarding the "hopeless >> top-level": Is this the least-bad option available or an unexpected >> consequence? >> >> --Dan > > The expansion in the repl is: > >> (syntax->datum > (expand > '(define (range lo) > (lambda (hi) (if (> lo hi) null (cons lo ((range (+ 1 lo)) hi))))))) > > '(define-values > (range) > (lambda (lo) > (lambda (hi) > (if (#%app > lo hi) > null > (#%app cons lo (#%app (#%app range (#%app + '1 lo)) hi)))))) > > The tricky thing here is that the meaning of a define-values form is > dependent on context: > > In an internal-definition context (see Internal Definitions), a > define-values form > introduces local bindings. > > At the top level, the top-level binding for each id is created > after evaluating expr, > if it does not exist already, and the top-level mapping of each id > (in the namespace linked with the compiled definition) is set to the > binding > at the same time. > > An the documentation on an internal-definition context says: > > A define-values form: The lexical context of all syntax objects > for the body > sequence is immediately enriched with bindings for the define-values form. > > http://docs.racket-lang.org/reference/define.html?q=define-values&q=repl#(form._((quote._~23~25kernel)._define-values)) > > -- > Jens Axel Søgaard > > > -- > -- > Jens Axel Søgaard -- -- Jens Axel Søgaard ____________________ Racket Users list: http://lists.racket-lang.org/users