[racket-dev] Scribble Racket Code with Here Strings

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Oct 30 14:56:04 EDT 2010

Yesterday, Doug Williams wrote:
> I sometimes use here strings for readability when building queries,
> etc.  For example:
> 
> (let-values (((variables results)
>               (get-repository-query-tuple r
> #<<---
> select * from {x} sys:repositoryID {y}
> using namespace
>   sys = <http://www.openrdf.org/config/repository#>
> ---
>                                          
> #:query-language 'SERQL)))
>   (printf "Repository ids = ~s~n"
>           (for/list ((bindings (in-list results)))
>             (binding-string (bindings-ref bindings 'y)))))

Unrelated to your question -- the scribble reader syntax is intended
to make it easier to use text blocks.  You could make
`get-repository-query-tuple' get a rest argument with strings to be
concatenated, and then use

  (let-values ([(variables results)
                @get-repository-query-tuple[r #:query-language 'SERQL]{
                  select * from {x} sys:repositoryID {y}
                  using namespace
                    sys = <http://www.openrdf.org/config/repository#>
                }])
    ...)


> But I haven't found a good way to document this (as Racket code) in Scribble.
> Everything I've tried renders like:
> 
>   (let-values (((variables results)
>                 (get-repository-query-tuple
>                  r
>   "select * from {x} sys:repositoryID {y}\r\nusing namespace\r\n  sys = <
> http://www.openrdf.org/config/repository#>\r"
>   
>   
>   
>   
>                  #:query-language 'SERQL)))
>     (printf "Repository ids = ~s~n"
>             (for/list ((bindings (in-list results)))
>               (binding-string (bindings-ref bindings 'y)))))
> 
> 
> That is, the here string has been rendered as a normal string with lots of
> whitespace after.

There's lots of ways to create strings and the documentation system
can't tell them apart -- so it rendered it as a string, but then
noticed that the other pieces of code are a few lines later.

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


Posted on the dev mailing list.