On 11/24/2012 05:36 PM, Eli Barzilay wrote:
I'm probably missing the problem, which wouldn't be surprising since I
didn't even tried to look up the `array' documentation...

Well, it didn't exist until I pushed it on Saturday night, so looking it up wouldn't have done you any good. :D

But, there are two things that seem relevant:

1. For just plain vector syntax, you still have quasiquotes do the
    usual thing, it only happens that #(...)s are implicitly quoted.
[...]

I... did not know that. Thanks!

2. Alternatively, the last paragraph that you wrote above can also be
    easily translated by just replacing "[" with "#(", so the array
    macro distinguishes its contents based on that:
      -> (define-syntax foo
           (syntax-rules ()
             [(foo #(x ...)) (list 'array x ...)]
             [(foo x)        (list 'datum x)]))
      -> (foo (+ 1 2))
      '(datum 3)
      -> (foo #((+ 1 2)))
      '(array 3)
    It's obviously a trivially simple example, but if you currently
    just dispatch on the paren-shape, then using #(...) instead should
    work just as well, be more robust, and not introduce the
    shape-dependent feature.

Am I missing something?

Nope. This works really well, so thanks for the fantastical idea. I'm keeping it.

I considered having array data implicitly quoted, like in vector syntax. With nested data, though, the number of design options grows quickly, the rules get complicated, and printing becomes a nightmare.

For example, it's common to have arrays of Indexes, or (Vectorof Index), which would have to print like this with implicit quoting:

  (array `#[,'#(0 0) ,'#(0 1)])

Just working out the algorithm to print such a thing made me want to curl up and whimper.

Neil ⊥

_________________________
 Racket Developers list:
 http://lists.racket-lang.org/dev

Reply via email to