On Thu, Aug 16, 2018 at 07:25:42PM -0400, Deren Dohoda wrote:
> >
> > Thanks for the up-vote but let me explain the “local” rationale here and
> > vote for the ‘inner define’ variant.
> > [snip]...
> >
> >
> > In Racket programs for the world, possibly real, you want to avoid
> > rightward drift. I
Bob Heffernan wrote on 08/16/2018 12:43 PM:
When it comes to nesting (which, I guess, means the use of let) vs
internal defines: is this purely an aesthetic thing?
I think, practically, you could call it only aesthetic, since the PLT
developers are invested in making internal `define` work a
With just a few more parentheses, I have a macro that lets you write:
(def
[x 0]
[y 1]
[z 2]
;; or even
[(f x) (/ (+ x y) z)])
http://docs.racket-lang.org/adjutor/Stable.html#(form._((lib._adjutor%2Fmain..rkt)._def))
I like explicit delimiters, but I agree that a bunch of one-line `defi
Have you ever considered extending the grammar of define from this:
(define id expr)
(define (head args) body ...+)
To this:
(define id expr ... ...); <-- like e.g. `hash`
(define (head args) body ...+)
So we could write things like:
(define x 0
y 1
z 2)
Sometimes so much
>
> Thanks for the up-vote but let me explain the “local” rationale here and
> vote for the ‘inner define’ variant.
> [snip]...
>
>
> In Racket programs for the world, possibly real, you want to avoid
> rightward drift. Indenting deeper and deeper makes code appear ‘ugly’ to
> many eyes, especially
On Thu, Aug 16, 2018 at 10:25 AM Matthias Felleisen
wrote:
> > On Aug 16, 2018, at 8:22 AM, Robert Girault
> > wrote:
> >
> > 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
On 18-08-16 11:43, 'Paulo Matos' via Racket Users wrote:
> 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))
Than
> On Aug 16, 2018, at 8:22 AM, Robert Girault
> wrote:
>
> 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'
On Thu, Aug 16, 2018 at 6:44 AM 'Paulo Matos' via Racket Users
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:
> >
> >
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)])
>
As others said, naming intermediate values can make things clearer.
(Taken too far, maybe it's hard to see the forest for the trees? I
think it depends on the audience and the domain.)
You happened to choose an example that illustrates a reason maybe not
to do this with let* or define -- cleaning
>
>
>
> My question is: is the way I'm writing things considered to be bad
> style? It feels like a hangover from more imperative-style programming
> & the inclination to do one thing "per line". On the other hand, it
> often helps readability.
>
I invariably write my code like this. I just thin
12 matches
Mail list logo