From aff9862c52acb5aa7e71dbbb058bc5e68e0ff82e Mon Sep 17 00:00:00 2001 From: Matthias Felleisen Date: Wed, 26 Dec 2012 21:52:02 -0500 Subject: [PATCH] [Style] added warning about define vs let star; see mailing list --- collects/scribblings/style/constructs.scrbl | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/collects/scribblings/style/constructs.scrbl b/collects/scribblings/style/constructs.scrbl index 323078e75b..94add06ce3 100644 --- a/collects/scribblings/style/constructs.scrbl +++ b/collects/scribblings/style/constructs.scrbl @@ -72,6 +72,37 @@ racket ] ] +@bold{Warning} A @racket[let*] binding block is not easily replaced with a +series of @racket[define]s because the former has @emph{sequential} scope +and the latter has @emph{mutually recursive} scope. +@compare[ +@racketmod[#:file +@tt{works} +racket +(define (print-two f) + (let* ([_ (print (first f))] + [f (rest f)] + [_ (print (first f))] + [f (rest f)]) + (code:comment "IN") + f)) +] +@; ----------------------------------------------------------------------------- +@racketmod[#:file + +@tt{does @bold{not}} +racket + +(define (print-two f) + (print (first f)) + (define f (rest f)) + (print (first f)) + (define f (rest f)) + (code:comment "IN") + f) +] +] + @; ----------------------------------------------------------------------------- @section{Conditionals}