[erlang-questions] tail recursion question

Richard O'Keefe ok@REDACTED
Thu Apr 29 00:12:37 CEST 2010


On Apr 28, 2010, at 8:01 PM, Valentin Micic wrote:

> On 2010/04/28 3:58 AM, "Richard O'Keefe" <ok@REDACTED> wrote:
>
>> However, it would be far
>> more useful for the compiler to report a "dead code" warning:
>
> As far as I can recollect -- this is what Erlang compiler does, right?

Wrong.  Try typing in this little module.

-module(foo).
-export([f/1]).

f(N) ->
     f(N+1),
     g(N).

g(N) ->
     exit(N).


This is an example of the kind of code we're talking about,
where the g(N) call is in fact dead because the f(N+1) call
cannot return.  In order to report the g(N) call as dead,
the compiler would have to *notice* that f/1 never returns.
It doesn't.  The compiler is completely silent about this.

That's not a complaint.




More information about the erlang-questions mailing list