[racket-dev] Code micro-level organization

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Wed May 30 17:55:34 EDT 2012

On 05/30/2012 03:40 PM, Eli Barzilay wrote:
> Now, lets imagine that instead of a simple `<>' hole, there are two
> kinds of holes with an "up" or a "down" direction -- this leads to
> this kind of a syntax:
>
>   (○ "foo bar baz"
>      (substring ↑ 3 8)
>      (string-trim ↑)
>      (let ([str ↑]) ↓)
>      (and (regexp-match? #rx"^[a-z].*[a-z]$" str) ↓)
>      (string-append "*" str "*"))
>
> where you can read `↑' as "the above" and `↓' as "the below".  The
> thing that makes me excited about this is how you can read this as the 
> above [*] reading.

Maybe a simpler proposal is just a 'last' identifier that is always bound to the previous expression? I think having two arrows could get confusing. I'm not really a fan of the `let' expression binding `str' in the scope of all the expressions below it since they only occur in the `let' due to the down arrow.

But with "last" it would be:

  (* "foo bar baz"
      (substring last 3 8)
      (string-trim last)
      (let ([str last])
         (* (string-append "*" str "*"))
             (and (regexp-match ... str) last)))

Having expressions come from the bottom, using the down arrow, seems sort of wierd.

Posted on the dev mailing list.