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

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

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.