I noticed that in the Java reference implementation of HGrid, that a grid with no columns has a dummy "empty" column injected. This seems unnecessary. The grammar for Zinc seems to handle a zero column case. Such a grid would just encode as
ver:"2.0"
\newline ;; no columns, no rows, no more grids. all done.
Or multiple grids would encode as:
ver:"2.0"
\newline ;; no columns
\newline ;; no rows, but more grids coming...
ver:"2.0"
id,dis,site,area
@whitehouse,"White House",M,55000
Or is it even meaningful to "zinc" a grid that has no column definitions? Should it just be an error?
Brian FrankTue 23 Oct 2012
Technically you are required to have one column. The grammar is:
<cols> := <col> ["," <col>]* <nl>
It is sort of an odd boundary condition. I guess the design should be the lesser of two evils: one dummy column or zero columns. My thoughts was that no columns would create a lot more bugs, but love to hear other opinions if everyone rather allow zero columns.
Matthew GianniniTue 23 Oct 2012
Doh! You, of course, are right about the grammar.
My thoughts are
1) Leave the grammar as it is (require at least one column). Inject "dummy" column in case that no columns are given.
2) Don't allow zero columns. It is an error.
3) Change the grammar to allow zero columns. If there are no columns, then no rows should be encoded.
I prefer #2 because it really seems like an error condition. As it stands now, if you inject an "empty" column, and then encode 1000 rows, you will just have 1000 rows that look like this
ver:"2.0"
empty
,\newline
,\newline ;; etc.....
Brian FrankTue 23 Oct 2012
Not sure what difference is between 1 and 2? There are cases where you need to encode a grid where all your care about is the meta, and not the columns/rows. A good case is error grids.
Matthew GianniniTue 23 Oct 2012
In that case would #3 seem acceptable to you? There is just something that feels wrong about choosing an arbitrary column name when the user does not supply any explicit columns.
Brian FrankWed 24 Oct 2012
I don't really like arbitrary column name either. But I think the other option is even worse. Saying you can have zero columns but have to have two newlines in your encoding seems like it is begging for trouble. Plus the original inspiration here was CSV which is pretty much same thing - you have to specify at least a column header even if you have no rows.
Matthew Giannini Mon 22 Oct 2012
I noticed that in the Java reference implementation of HGrid, that a grid with no columns has a dummy "empty" column injected. This seems unnecessary. The grammar for Zinc seems to handle a zero column case. Such a grid would just encode as
Or multiple grids would encode as:
Or is it even meaningful to "zinc" a grid that has no column definitions? Should it just be an error?
Brian Frank Tue 23 Oct 2012
Technically you are required to have one column. The grammar is:
It is sort of an odd boundary condition. I guess the design should be the lesser of two evils: one dummy column or zero columns. My thoughts was that no columns would create a lot more bugs, but love to hear other opinions if everyone rather allow zero columns.
Matthew Giannini Tue 23 Oct 2012
Doh! You, of course, are right about the grammar.
My thoughts are
1) Leave the grammar as it is (require at least one column). Inject "dummy" column in case that no columns are given.
2) Don't allow zero columns. It is an error.
3) Change the grammar to allow zero columns. If there are no columns, then no rows should be encoded.
I prefer #2 because it really seems like an error condition. As it stands now, if you inject an "empty" column, and then encode 1000 rows, you will just have 1000 rows that look like this
Brian Frank Tue 23 Oct 2012
Not sure what difference is between 1 and 2? There are cases where you need to encode a grid where all your care about is the meta, and not the columns/rows. A good case is error grids.
Matthew Giannini Tue 23 Oct 2012
In that case would #3 seem acceptable to you? There is just something that feels wrong about choosing an arbitrary column name when the user does not supply any explicit columns.
Brian Frank Wed 24 Oct 2012
I don't really like arbitrary column name either. But I think the other option is even worse. Saying you can have zero columns but have to have two newlines in your encoding seems like it is begging for trouble. Plus the original inspiration here was CSV which is pretty much same thing - you have to specify at least a column header even if you have no rows.