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

From: Neil Toronto (neil.toronto at gmail.com)
Date: Fri Nov 23 17:46:55 EST 2012

Without extra assumptions, it's impossible to tell what's supposed to be 
an element and what's supposed to be a row. For example, this is ambiguous:

   (array ((list 1 2)))

It could be a one-dimensional array containing just '(1 2), or a 1x3 
array containing 'list, '1 and '2.

My current "extra assumption" is that "[" means "this is a row", and 
anything else means "this is an element". The extra assumption could 
also be that everything is quasiquoted, and then the shape of the parens 
wouldn't matter.

Neil ⊥

On 11/23/2012 03:35 PM, Robby Findler wrote:
> Okay, I can't resist: why not use parens?
>
> On Fri, Nov 23, 2012 at 4:31 PM, Neil Toronto <neil.toronto at gmail.com> wrote:
>> On 11/23/2012 03:03 PM, Robby Findler wrote:
>>>
>>> That [implicitly quasiquoting array data] sounds crazy, man. How about
>>> #:keywords instead?
>>
>>
>> Like this?
>>
>>    (array #:keywords (list) ((list 1 2)))
>>
>> Deciding how to print elements would be a problem.
>>
>>
>>> If not, then I
>>> think you're better off just going with identifiers.
>>
>>
>> I'm trying to avoid them because I find this hard to read:
>>
>>    (array (array-row
>>            (array-row (array-row "00" "01" "02"))
>>            (array-row (array-row "10" "11" "12"))
>>            (array-row (array-row "20" "21" "22"))
>>            (array-row (array-row "30" "31" "32"))))
>>
>> The keywords get in the way. This isn't an issue with any constructor of
>> flat data like `list', `vector' and #hash(). With those, your brain can
>> forget about the names that delimit the data because they're at the
>> beginning, but `array-row' is interspersed. (It's worse when the data are
>> different sizes.) Compare with this:
>>
>>    (array [[["00" "01" "02"]]
>>            [["10" "11" "12"]]
>>            [["20" "21" "22"]]
>>            [["30" "31" "32"]]])
>>
>> I read "this is an array," then a bunch of structured data.
>>
>> (Alternatively, think of how annoying #hash() would be if you had to type
>> and read (cons x y) instead of (x . y).)
>>
>> I didn't mind #() because "#" isn't too intrusive. I don't mind implicit
>> quasiquoting because most array data are going to be constants, so the
>> ugliness happens infrequently.
>>
>> I don't want to be stodgy about this, but I also don't want people thinking,
>> "Oh, that's hideous" the first time they see an array printed. I'm also
>> aware that this is dangerously close to bikeshedding... :/
>>
>> Neil ⊥
>>


Posted on the dev mailing list.