<p>(sorry for the bad indentation, writing s-exps on a phone predictive keyboard is painful...) </p>
<div class="gmail_quote">Le 31 mai 2012 19:21, "Laurent" <<a href="mailto:laurent.orseau@gmail.com">laurent.orseau@gmail.com</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>How about a define* that is exactly like let* without the additional indentation level? <br>
E.g.:<br>
<br>
(define*<br>
[↑ "foo bar baz"]<br>
[↑ (substring ↑ 3 8)]<br>
[str (string-trim ↑)]<br>
[↑ (regexp-match? #rx"^[a-z].*[a-z]$" str)]) <br>
(and ↑ (string-append "*" str "*")) </p>
<p>Laurent </p>
<p>Le 31 mai 2012 19:04, "Neil Toronto" <<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a>> a écrit :<br>
><br>
> On 05/30/2012 03:40 PM, Eli Barzilay wrote:<br>
>><br>
>> Now, lets imagine that instead of a simple `<>' hole, there are two<br>
>> kinds of holes with an "up" or a "down" direction -- this leads to<br>
>> this kind of a syntax:<br>
>><br>
>> (○ "foo bar baz"<br>
>> (substring ↑ 3 8)<br>
>> (string-trim ↑)<br>
>> (let ([str ↑]) ↓)<br>
>> (and (regexp-match? #rx"^[a-z].*[a-z]$" str) ↓)<br>
>> (string-append "*" str "*"))<br>
>><br>
>> where you can read `↑' as "the above" and `↓' as "the below".<br>
><br>
><br>
> It seems like `↑' is another way to not name expressions (i.e. a "pointless style" :D), and `↓' is handled just fine by internal definitions. This is equivalent, currently defined, has less nesting, and avoids a rename:<br>
><br>
> (define orig-str "foo bar baz")<br>
> (define sub (substring orig-str 3 8))<br>
> (define str (string-trim sub))<br>
> (define m (regexp-match? #rx"^[a-z].*[a-z]$" str))<br>
> (and m (string-append "*" str "*"))<br>
><br>
> A `define*' form like Jay (and I) want would make these kinds of things less error-prone and allow names to be reused:<br>
><br>
> (define* ↑ "foo bar baz")<br>
> (define* ↑ (substring ↑ 3 8))<br>
> (define* str (string-trim ↑))<br>
> (define* ↑ (regexp-match? #rx"^[a-z].*[a-z]$" str))<br>
> (and ↑ (string-append "*" str "*"))<br>
><br>
> It's still pretty wordy, though. Even if I had `define*' I'd be tempted to go with my current favorite idiom, which trades wordiness for a nesting level:<br>
><br>
> (let* ([↑ "foo bar baz"]<br>
> [↑ (substring ↑ 3 8)]<br>
> [str (string-trim ↑)]<br>
> [↑ (regexp-match? #rx"^[a-z].*[a-z]$" str)])<br>
> (and ↑ (string-append "*" str "*")))<br>
><br>
> I occasionally get annoyed by how deeply these can get nested. I feel your pain, man.<br>
><br>
> Neil ⊥<br>
><br>
> _________________________<br>
> Racket Developers list:<br>
> <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
</p>
</blockquote></div>