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

From: Neil Toronto (neil.toronto at gmail.com)
Date: Fri Nov 23 16:39:18 EST 2012

On 11/23/2012 01:47 PM, Neil Toronto wrote:
> On 11/22/2012 11:33 AM, Eli Barzilay wrote:
>> Two days ago, Neil Toronto wrote:
>>> Anyway, it occurred to me that I need to provide a more robust way
>>> to generate code for literal arrays anyway. Keywords are more easily
>>> preserved by macros than syntax properties:
>>
>> Why not use vector syntax #(...) instead of [...]?
>
> That is a fantastic idea. Thanks!
>
> (The problem I was having with head identifiers like `array-row' was
> that they got in the way when I was reading the array. Vector syntax
> solves that neatly.)

I've thought about it more and come up with a weird case:

   (array #((list 1 2)))

Should this array contain '(1 2) or '(list 1 2)?

I'm not keen on the idea of the `array' macro only being useful for 
quoted datums, especially since it's not a reader macro. But if the 
above array contained '(1 2), that would be inconsistent with #((list 1 
2)), which contains '(list 1 2):

   > (vector-ref #((list 1 2)) 0)
   '(list 1 2)

I've considered having `array' implicitly quote its contents, so

   (array ((list 1 2)))

contains '(list 1 2), but

   (array (,(list 1 2)))

contains '(1 2).

That might actually work the way I want it to. Do you see any problems 
with it?

Neil ⊥


Posted on the dev mailing list.