On Thu, Aug 16, 2018 at 6:44 AM 'Paulo Matos' via Racket Users <racket-users@googlegroups.com> wrote: > On 11/08/18 16:11, Bob Heffernan wrote: > > Dear all, > > > > I am new to Racket and only slightly less new to scheme & scheme-like > > languages. > > > > I have noticed myself often doing something like the following: > > > > (define (foo x) > > (let* ([y (f x)] > > [z (g y)] > > [p (h z)]) > > (bar p))) > > I really, really don't like nesting and a few years ago adopted the > style of internal defines. It makes for much more readable code: > > (define (foo x) > (define y (f x)) > (define z (g y)) > (define p (h z)) > > (bar p)) > > I avoid nesting, long lines and short names. So I would try to name the > variables appropriatelly. If intermediate variables don't have a > 'meaning' such that they can be given proper names, maybe they don't > deserve to be a variable and instead I will compose.
I think I'd write your example like this. (define (foo x) (local ((define y (f x)) (define z (g y)) (define p (h z))) (bar p))) (If I knew what f, g, h do, I might write it differently. If they're all only for computing p, local expresses the fact.) I was educated by HtDP 1st edition: https://htdp.org/2018-01-06/Book/part_three.html#%28part._sec~3alocal-definitions%29 -- 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 to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.