[racket-dev] Square-bracket-sensitive macros in Scribble sandboxes

From: Neil Toronto (neil.toronto at gmail.com)
Date: Sun Nov 18 22:01:00 EST 2012

I'm writing the documentation for math/array, and the examples all fail. 
Here's a simple one:

   @examples[#:eval untyped-eval
                    (array [0 1 2 3])]

The evaluator raises this error:

   application: not a procedure;
    expected a procedure that can be applied to arguments
     given: 0
     arguments...:
      1
      2
      3

The problem here is that the `array' macro is sensitive to square 
brackets, but Scribble doesn't preserve the 'paren-shape syntax 
property. (Either that, or `examples' only sends lists to the evaluator, 
not syntax.) So (array [0 1 2 3]) gets evaluated as (array (0 1 2 3)), 
which looks like a zero-dimensional array containing (0 1 2 3), which is 
an application of the value `0'. Bad.

I know this can work just fine; for example, this does the expected 
thing in the REPL:

   > (eval #'(require math))
   > (eval #'(array [0 1 2 3]))
   (array [0 1 2 3])

Is there a way to get Scribble to behave like I expect?

Neil ⊥

Posted on the dev mailing list.