# \[feature request\] Allow circular function definitions

**URL:** <https://talk.observablehq.com/t/feature-request-allow-circular-function-definitions/4554>\
**Category:** Feedback\
**Created:** [January 31, 2021, 8:05am UTC](https://talk.observablehq.com/t/feature-request-allow-circular-function-definitions/4554 "2021-01-31T08:05:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kikkupico](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kikkupico/32/4297_2.png) [@kikkupico](https://talk.observablehq.com/u/kikkupico)\
**Post date:** [January 31, 2021, 8:05am UTC](https://talk.observablehq.com/t/feature-request-allow-circular-function-definitions/4554/1 "2021-01-31T08:05:58Z")

</div>

Some circular function definitions are valid as illustrated in [https://observablehq.com/@vramakin/valid-cycles](https://observablehq.com/@vramakin/valid-cycles) but Observable always throws an error when it sees a circular definition. This prevents valid mutually recursive functions from being defined. So, can the circular definition check be disabled for function definitions ? I understand this is a rarely used feature; it will be nice to have it though.

---

<div class="post-metadata">

**Author:** ![jrus](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jrus/32/586_2.png) [@jrus](https://talk.observablehq.com/u/jrus)\
**Post date:** [January 31, 2021, 8:33pm UTC](https://talk.observablehq.com/t/feature-request-allow-circular-function-definitions/4554/2 "2021-01-31T20:33:51Z")

</div>

> it will be nice to have it though

Do you have a concrete/practical case where you have wanted this?

---

<div class="post-metadata">

**Author:** ![kikkupico](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kikkupico/32/4297_2.png) [@kikkupico](https://talk.observablehq.com/u/kikkupico)\
**Post date:** [February 1, 2021, 8:25am UTC](https://talk.observablehq.com/t/feature-request-allow-circular-function-definitions/4554/3 "2021-02-01T08:25:19Z")

</div>

I was trying to use mutual recursion for a backtracking algorithm. After refactoring I realise the code reads better without mutual recursion. I’ll post here if I find more concrete cases.

FYI, the backtracking algorithm was something like this -

```
function solve(inp, op):
    if(deadEnd) return stepBack(inp,op)
    else if(goodEnd)
        accumulate(op)
        return stepBack(inp,op)
    else return solve(next(ip),op)
    
function stepBack(inp, op):
    if(backToStart) return op
    else return solve(prev(inp),prev(op))
```
