Support for relative cell references
It would be really cool if we could support relative cell references. For example, wherever we allow a * in a reference we should be able to modify it by following it with a + or - followed by a number, in order to refer to a cell relative to the current cell. It could look something like this:
Option 1:
@A(*+2)
@B(*-1)
@(*+3)1
@(*+3)*
@*(*-2)
@(*+3)(*-2)
Option 2:
@A*(+2)
@B*(-1)
@*(+3)1
@*(+3)*
@**(-2)
@*(+3)*(-2)
Option 3:
@A{*+2}
@B{*-1}
@{*+3}1
@{*+3}*
@*{*-2}
@{*+3}{*-2}
Option 4:
@A*{+2}
@B*{-1}
@*{+3}1
@*{+3}*
@**{-2}
@*{+3}*{-2}
Note: The use of some kind of parenthesis is necessary in order to avoid ambiguity for references like @*+134, which in absence of some grouping of the numbers could be interpreted either as @(*+13)4 (i.e. cell at current column + 13 and row 4) or as @(*+1)34 (i.e. cell at current column + 1 and row 34)
I think I like most Option 4. Comments on these and suggestions for different representations are welcome.
We could also introduce some new directives to achieve this, such as mm:cellColumnModif and mm:cellRowModif. For example:
Individual: @**(rdfs:label)
Types: @*1
Facts: hasValue @**(xsd:decimal),
hasTimestamp @**(xsd:dateTime mm:cellColumnModif=+4)
or
Individual: @**(mm:uuidEncode)
Facts: hasYear @*1(xsd:integer)
hasFemaleCount @**(xsd:integer),
hasMaleCount @**(xsd:integer mm:cellRowModif=+25)
Here is a concrete use case for the need of this kind of relative reference: http://protege-project.136.n4.nabble.com/Ontology-Instanciation-tp4666155p4666407.html
This use case came up several times in the past too and I have always thought that it would be cool to have relative references.
How about mm:columnOffset and mm:rowOffset for the directive names?
These directive would take a single integer parameter.
An example could be:
@A*(mm:rowOffset=2 mm:columnOffset=-3)
The plus could be used before the number because it would be part of a valid integer but it would not be needed.
As you discovered, the ambiguity due to row numbers and the '+' symbol make it hard to find a concise syntax. (And even if we decided on a different symbol for last row or column the ambiguity would still be there because of row numbers.)
I think I prefer Option 4 too, even though it is not particularly elegant. There may be no elegant answer here. Perhaps just support the suggested directives? They would certainly be easier to implement and would not involve a grammar change.
I dug up some old notes I had in the office. These have a comma separating the column from the row, e.g.,
@A,*+3
@*-2,*+3
@*+3,12
@A,3 # Same as @A3
Here
@<column>,<row>
is effectively the same as
@<column><row>
with the comma needed only for disambiguation.
I really like the idea with the explicit directives mm:rowOffset and mm:columnOffset. In fact I thought about these names myself this morning (with a slight variation), as being a much better solution than the one that I came up last night. I think that this would be cleaner and easier to implement, so I suggest we go with this.