Hello,

I am looking at the parsing of org-table formula mode strings and I find
it quite confusing and I have an hard time understanding if it works the
way it does by design or by accident.

Formula mode strings are documented here

https://orgmode.org/manual/Formula-syntax-for-Calc.html#Formula-syntax-for-Calc

but the specification is not very strict and the parser implements
surprising behaviors. Would it make sense to tighten the specification
and the implementation?

I think being a bit more strict is what is accepted would help catching
typos and mistakes, but I am not sure that having formulas resulting in
#ERROR upon an org-mode upgrade is desirable. Also, maybe a specific
marker (#INVALID ?) should be used for invalid syntax.

The main problem with the current parsing code is that any character
that is not recognized as a valid mode flag is used as a value format
string. For example:

| 1 | 2 | OO3.000 |
#+TBLFM: $3=$1+$2;FOO%.3f

Is this by design? If so, what is the use case?

Thus is slightly more surprising:

| 1 | 2 | 3.000 OO |
#+TBLFM: $3=$1+$2;%.3f FOO

I argue the first form should result in an error. The second can either
result in an error or in everything following the % sign to be used as a
format string, although I am not sure there is a clear use case for this.

Thank you.

Cheers,
Dan

Reply via email to