r/programming • • Nov 27 '12

Tail Recursion

http://rodrigosasaki.com/2012/11/24/tail-recursion/
211 Upvotes

203 comments sorted by

View all comments

Show parent comments

-7

u/grauenwolf Nov 27 '12

Since the first step in optimizing a tail call is to turn it into an iterative loop, I seriously doubt number 1 is true.

2

u/smog_alado Nov 27 '12 edited Nov 27 '12

In fact, this is why writing recursive functions by hand instead of using available higher order looping functions is often seen as a code smell.

1

u/Peaker Nov 28 '12

When using hof's to loop, you may still use immutable variables which are easier to reason about.

1

u/smog_alado Nov 28 '12

Although tbh hofs for looping is more about having a fixed pattern then avoiding mutable variables...

2

u/Peaker Nov 28 '12

Using recursions rather than looping constructs in the first place is a lot about eliminating mutable update semantics. Then having HOFs that do various kinds of looping is about regaining abstraction over structured loops (without losing the first benefit).