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

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Nov 18 22:12:48 EST 2012

(Perhaps this suggests a problem with making a macro depend on the shape of parens around a sub-expression.) 




On Nov 18, 2012, at 10:01 PM, Neil Toronto wrote:

> 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 ⊥
> _________________________
> Racket Developers list:
> http://lists.racket-lang.org/dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20121118/c5207745/attachment-0001.p7s>

Posted on the dev mailing list.