Launched: Reuse logic and create nested loops with the new WithName() formula

Hi @shishir,

First of all, I <3 Coda and am so thankful you made such a great platform. I’ve built business tools on top of Coda that go far beyond what some commercial off-the-shelf products can do. It’s incredible!

That being said (and I realize this may sound pedantic), the current syntax of WithName is a minor but consistent annoyance. When I use it many times within a complicated formula, it can make the whole thing very hard to read and follow along, as well as make the auto-indenter useless. I understand the issue you mentioned with formula editor order / auto complete as well as mid-expression var-args being outside of your parser’s design. However, have you considered transforming the formula editor before processing? I am unaware of how things work under the hood, so I could be wrong, but could you rewrite a new formula WithNames(xN,xS,yN,yS,E) behind the scenes (before general parsing) to match your current syntax of WithName(xS,xN,WithName(yS,yN,E))?

There are three issues I see:

  1. The overuse of parens and the need to balance them, rendering the auto-indenter useless.
  2. Brevity and clarify.
  3. I feel strongly that names should be first. This is much easier to work with. In pretty much all programming languages you write x = blah blah blah, not blah blah blah → X. The reason for this is that 1) variable names are shorter and easier to alight vertically, and 2) it makes it easier to find what the definition of a variable is. I’m guessing you did it this way so someone could write [value].WithName([var], [expression]), so maybe this was unavoidable.

Here is my suggestion:

WithNames(
  name1, s1,
  name2, s2,
  expr)

rather than either:
WithNames(s1, name1, s2, name2, expr)
or the current:
WithName(s1, name1, WithName(s2, name2, expr))

On a non-sequitur, my other biggest annoyance is that If([x].IsBlank(),"blah",[x].[column]) in a canvas formula returns an error rather than "blah" when [x] is blank. This requires annoying workarounds like using a one-row table. I’m surprised Coda hasn’t implemented short-circuiting.

3 Likes