functional-programmingcontinuation-passing

Does it make sense to call continuation-passing style the rescue for functional programming languages?


I am unsure if the following statements make sense:

  1. Invoking a non-tail-recursive function in a functional programming languages has, typically, a space efficiency problem due to growing call stacks.

  2. Each non-tail-recursive function can be systematically transformed to a tail-recursive one by transforming the function call to continuation-passing style.

  3. Continuation-passing style is the rescue for functional programming languages because without it, non-tail-recursive functions which prevail in code base of functional programming languages would necessarily cause significant performance issues.


Solution

  • This is totally wrong. While every function can by systematically transformed into on that use continuation passing style, this does not solve space efficiency problems of an algorithm. The space might be allocated in the continuation closure instead of on the execution stack, but that makes no difference.

    (Also, this has nothing do with a language being functional or not.)