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

**URL:** <https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900>\
**Category:** News from Superhuman\
**Created:** [December 2, 2020, 10:06pm UTC](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900 "2020-12-02T22:06:18Z")\
**Posts on this page:** 5\
**Page:** 3

<div class="post-metadata">

**Author:** ![Chris\_Jennings](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/chris_jennings/32/13280_2.png) [@Chris\_Jennings](https://connect.superhuman.com/u/Chris_Jennings)\
**Post date:** [February 4, 2022, 5:34pm UTC](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900/42 "2022-02-04T17:34:03Z")

</div>

Already redid one of my formulas with this and it worked like a charm. Thanks Coda!

---

<div class="post-metadata">

**Author:** ![Matthew\_Strax-Haber](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@Matthew\_Strax-Haber](https://connect.superhuman.com/u/Matthew_Strax-Haber)\
**Post date:** [March 9, 2023, 3:32pm UTC](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900/43 "2023-03-09T15:32:46Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Tamerlan\_Kagarmanov](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@Tamerlan\_Kagarmanov](https://connect.superhuman.com/u/Tamerlan_Kagarmanov)\
**Post date:** [November 13, 2023, 5:46pm UTC](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900/44 "2023-11-13T17:46:06Z")

</div>

> [@Launched: Reuse logic and create nested loops with the new WithName() formula](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900/43):
>
> 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 use…

+1 I agree, it’s inconvenient.

---

<div class="post-metadata">

**Author:** ![joost\_mineur](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/joost_mineur/32/30539_2.png) [@joost\_mineur](https://connect.superhuman.com/u/joost_mineur)\
**Post date:** [November 14, 2023, 12:21am UTC](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900/45 "2023-11-14T00:21:33Z")

</div>

I don’t agree or disagree, but I think it is sort of a non-issue. Any programming language has it’s own somewhat peculiar things - and this one really isn’t that bad.  
I try to format my CFL in such a way that I can easily see the stucture of my (more complicated) CFL. I have triple or quadripple nested WithNames’ and honestley, I think it is very readable.  
The following looks nice ‘on paper’:  
WithNames(  
name1, s1,  
name2, s2,  
expr)  
but with ‘real code’ that stretches over multiple lines in the editor, the current structure might be easier to recognize than this.

If @Coda\_hq wants to honor this, the function needs a new name in order to not break existing code. The suggestion to put the name of the WithName variable first intuitively makes sense to me though.

---

<div class="post-metadata">

**Author:** ![Pawel\_Niewiadomski1](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/pawel_niewiadomski1/32/42677_2.png) [@Pawel\_Niewiadomski1](https://connect.superhuman.com/u/Pawel_Niewiadomski1)\
**Post date:** [June 10, 2024, 3:15pm UTC](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900/46 "2024-06-10T15:15:51Z")

</div>

That was one of the hardest things to find in coda 🤯

I’ve spent hours and hours searching for the solution of CurrentValue being overriden only to learn there’s WithName :tears-of-joy:

[Previous page](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900.md?page=2)
