[erlang-questions] tail-recursive functions

Mikael Pettersson <>
Thu Jan 29 13:18:38 CET 2009


Vlad Dumitrescu writes:
 > Hi,
 > 
 > Reading the new EEP 26 "Make andalso and orelse tail-recursive" (which
 > I'm in favor for, btw) made me think of a side-effect: it will become
 > less easy to see if a function is tail-recursive or not.
 > I mean, one has to actively look at the operator and decide "it's
 > andalso, it's tail-recursive" or "it's and, it's not tail-recursive".
 > In addition, there were discussions about making other constructs
 > tail-recursive too.

I don't follow this argument. It's always been the case that
you have to look at a function's body to determine whether it's
tail-recursive or not. Making andalso/orelse tail-recursive
doesn't significantly change that.

Even procedural languages have similar properties, c.f. short-circuited
boolean operators like C's && and ||: you have to look at the operator
to determine if the second operand is evaluated or not.

/Mikael



More information about the erlang-questions mailing list