Rho! Cute!
I just realized that implicit quasiquoting won't work, for exactly the
same reason not quasiquoting doesn't work: (array ((1 2))) is still
ambiguous. If "(" always meant "row" then "," could be an escape, but
(array (,'(1 2))) is also hideous, and so is (array ,'(1 2)).
I'm starting to think #() for rows with expressions allowed inside is my
least bad option. An array of literal vectors can be constructed by
quoting its elements. I'm'a go check it out.
Neil ⊥
On 11/23/2012 03:55 PM, Robby Findler wrote:
Oh, I see. I guess the best thing is to use the vector notation, but
insist that things are not quoted and the #() notation is used only to
say where the rows are (with expressions inside). You could also use a
one-letter identifier at the start of each parenthesized row:
(array [ρ [ρ [ρ "00" "01" "02"]]
[ρ [ρ "10" "11" "12"]]
[ρ [ρ "20" "21" "22"]]
[ρ [ρ "30" "31" "32"]]])
Robby
On Fri, Nov 23, 2012 at 4:46 PM, Neil Toronto <neil.toro...@gmail.com> wrote:
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.toro...@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 ⊥
_________________________
Racket Developers list:
http://lists.racket-lang.org/dev