[racket] why do I get undefined , when using internal definition?
Unless I'm being stupid at this hour, I think you've found a bug: either
it should work as you originally expected, or it should raise an error
to complain about an internal "define" referencing itself like that and
ignoring the pre-existing binding from the argument. Note that, if you
rename the internal binding to "color2" to reflect what you expected, it
works.
(define (make-color color)
(define color2 color)
color2)
Just between you and me, I never use internal "define". I came from
RnRS, where "define" was only used at top level, and top level is
fraught with witchcraft. "let", "let*", "let-values", and "let*-values"
are more straightforward, overall, IMHO.
Veer wrote at 07/10/2011 01:41 AM:
> (define (make-color color)
> (define color color)
> color)
>
> (make-color 'red) ;; => #<undefined>
>
--
http://www.neilvandyke.org/