[racket-dev] Code micro-level organization

From: Eli Barzilay (eli at barzilay.org)
Date: Wed May 30 18:07:11 EDT 2012

A few minutes ago, Jon Rafkind wrote:
> 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?

That's basically the (improved) thing that you get in clojure, and the
problem is that it doesn't fit nesting in the other way, which is what
`nest' does.  Something that I forgot to fill in the previous post is
that this could be one reason why they have the `-?>' and `-?>>'
forms: these things are dealing with conditional values, which is
something that you get with nesting that goes in the other direction.

(As for the identifier names, I think of them as "the above" and "the
below", so maybe those are better names.)


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

Here's a concrete example:

  (○ (let ([x 10]) ↓)
     (for ([i (in-range x)]) ↓)
     (for ([j (in-range i)]) ↓)
     ...etc...)

Do you have a concrete suggestion for doing that?

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.