<div dir="ltr">The "listification" of arguments within curly braces is easily the aspect of Scribble syntax that trips me up the most. I understand why it's done that way. But for my purposes, I usually want the thing between curly braces to behave as a block, not as a list. <div><br></div><div><div>For instance, in my Pollen package, I use Scribble for HTML templates, where you want to be able to write things like:</div><div><br></div><div>@when[condition]{print</div><div>all</div><div>the </div><div>stuff</div><div>here}</div><div><br></div><div>Anyone who's familiar with HTML template languages would expect everything between the curlies to print. But under Scribble rules, you only get the last word "here".</div><div><br></div><div>So I created a `when/block` macro that does the thing I want. [1] <br></div><div><br></div><div><div>@when/block[condition]{print</div><div>all</div><div>the </div><div>stuff</div><div>here}</div></div><div><br></div><div>I suppose it's similar to Eli's when* macro, though mine also does string conversions. For instance, when* won't work in this case, where a value is being returned within the curlies:</div><div><br></div><div><span class="im" style="font-size:12.7272720336914px">#lang scribble/base<br>    @(define some-condition #true)<br></span><span style="font-size:12.7272720336914px">    @(define-syntax-rule (when* C  E ...) (and C (list E ...)))</span><br></div><div><br></div><div><div>@when*[some-condition]{</div><div>      @section{Section two}</div><div>      AKA section @(+ 1 1)}</div></div><div><br></div><div><div>I thought about a) modifying Scribble syntax for my Pollen package so that curly braces behave this way by default (= no, because it breaks too much) or b) introducing new "block operator" syntax (= like double curly braces, but that doesn't save too many keystrokes, and we're running out of easily accessed grouping characters.) Though perhaps:</div></div><div><br></div><div><div>@when[condition]<print</div><div>all</div><div>the </div><div>stuff</div><div>here></div></div><div><br></div><div>?</div><div><br></div><div><span style="font-size:12.7272720336914px"><br></span></div><div><span style="font-size:12.7272720336914px"><br></span></div><div><br></div><div>[1] <a href="http://pkg-build.racket-lang.org/doc/pollen/Template.html#%28def._%28%28lib._pollen%2Ftemplate..rkt%29._when%2Fblock%29%29">http://pkg-build.racket-lang.org/doc/pollen/Template.html#%28def._%28%28lib._pollen%2Ftemplate..rkt%29._when%2Fblock%29%29</a></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 17, 2014 at 1:04 AM, Eli Barzilay <span dir="ltr"><<a href="mailto:eli@barzilay.org" target="_blank">eli@barzilay.org</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Dec 16, 2014 at 9:27 PM, Matthias Felleisen<br>
<<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>> wrote:<br>
><br>
> A 'when' expression returns the value of the last expression, in your<br>
> case the content of the section. By lifting the when out, you get both<br>
</span>> pieces: [...]<br>
<br>
After I complained about it a few times, Matthew made it possible to use<br>
lists, as well as some other other scribble/text-isms (like ignoring #f<br>
and void):<br>
<span class=""><br>
    #lang scribble/base<br>
    @(define some-condition #true)<br>
</span>    @title{Use Lists}<br>
<span class="">    @section{Section one}<br>
    Section one is for everyone.<br>
    @(when some-condition<br>
</span>       (list @section{Section two}<br>
<span class="">             "Section two is for some, but not all."<br>
</span>             "This is more satisfactory."))<br>
<br>
But it's more convenient to use the text syntax, and it works better in<br>
that you don't get the hard-to-find formatting bug that the above<br>
produced:<br>
<span class=""><br>
    #lang scribble/base<br>
    @(define some-condition #true)<br>
</span>    @title{Use Lists}<br>
<span class="">    @section{Section one}<br>
    Section one is for everyone.<br>
    @(when some-condition<br>
</span>       @list{@section{Section two}<br>
<span class="">             Section two is for some, but not all.<br>
</span>             This is more satisfactory.})<br>
<span class=""><br>
> This is clearly unsatisfactory but I am sure you can make this look<br>
> decent with a bit of macrology<br>
<br>
</span>A tiny bit of very simple macrology that can still be useful here is:<br>
<span class=""><br>
    #lang scribble/base<br>
    @(define some-condition #true)<br>
</span>    @(define-syntax-rule (when* C  E ...) (and C (list E ...)))<br>
<br>
    @title{Use Lists}<br>
<span class="">    @section{Section one}<br>
    Section one is for everyone.<br>
</span>    @when*[some-condition]{<br>
      @section{Section two}<br>
<span class="">      Section two is for some, but not all.<br>
<br>
</span>      This is more satisfactory.}<br>
<br>
[In my fantasies I get to redefine a #%begin[*] macro to `list'<br>
(actually, `begin/text') and that makes everything works as people<br>
usually expect.]<br>
<br>
And since lists have no rendering meaning (= they're just flattened) (at<br>
least that was how I wanted it, hopefuly it didn't change--?), you don't<br>
need tricks like `append-map' and similar:<br>
<span class=""><br>
    #lang scribble/base<br>
    @(define some-condition #true)<br>
</span>    @(define-syntax-rule (when* C  E ...) (and C (list E ...)))<br>
<br>
    @title{Use Lists}<br>
<span class="">    @section{Section one}<br>
    Section one is for everyone.<br>
<br>
</span>    @(define (triple . x) (build-list 3 (λ(_) (list x "\n" "\n"))))<br>
    @when*[some-condition]{<br>
      @triple{<br>
        @section{Section two}<br>
        @triple{Section two is for some, but not all.<br>
<br>
                This is more satisfactory.}}}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:<br>
                    <a href="http://barzilay.org/" target="_blank">http://barzilay.org/</a>                   Maze is Life!<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div></div>