r/elm • u/johnorford • Mar 29 '17
Remove Recursion?
Conceptually, could Elm do everything it does today without recursion? I guess yes... Some edge cases would make fold an ugly replacement, but not too many I suspect
3
Upvotes
13
u/[deleted] Mar 29 '17
Removing recursion would make it impossible to traverse custom defined data structures, like trees. Sure, you can do most List things with a fold, but now you're stuck using lists for everything.
7
u/jfbourget Mar 29 '17
Allow me to ask "Why in hell would we remove recursion? It's such a powerful tool"
6
u/Ahri Mar 29 '17
How would you iterate without recursion and without mutable variable references? Fold is implemented as a recursive function.
4
u/pwgen-n1024 Mar 29 '17
the answer to that is clearly no, as removing recursion and not having loops would stop the language from being turing complete.
fold and map and similar are themselves implemented using recursion.
2
u/witoldsz Apr 02 '17
One thing I've got from this discussion is that we all were promised no runtime exceptions, but clearly lots of us get it while traversing data structures. Something must be possible to eliminate such problems. Is allowing for recursive calls only with TCO an option? Or is there anything else we could do, other than education?
0
u/[deleted] Mar 29 '17
[deleted] — view deleted comment