[erlang-questions] Preprocessor bug?

Richard Carlsson richardc@REDACTED
Sat Feb 23 20:03:21 CET 2008


I have changed the inliner so that instead of reporting a
compile-time error (which was really the wrong thing to do),
it now quietly skips the attempt to inline the call if the
arities don't match. (The fix is simple: find the place
which prints the error report, and change it to return {E,S}
in case of arity mismatch. Or wait for the next OTP release.)

Handling is_function/2 would let it remove the redundant code
as well. I'm leaving that for later.

    /Richard

David King wrote:
> I'm not sure if this is a bug or, if it is a bug, it even needs to be  
> fixed. This code:
> 
> f(F,A) when is_function(F,1) ->
>    F(A);
> f(F,B) when is_function(F,2) ->
>    F(B,B).
> 
> main() ->
>    f(fun(a) ->
>          io:format("f(g/1): ~p~n",[a])
>      end, a),
>    f(fun(b,b) ->
>          io:format("f(g/2): ~p~n",[b])
>      end, b).
> 
> compiles and works as expected, unless -compile(inline) is specified.
> If -compile(inline) is specified, the compiler dies with "error:  
> function called with wrong number of arguments!". I would think that  
> when the pre-processor can't determine at pre-compile time which  
> clause to run, it just wouldn't run one, but this is a mess I know I'm  
> getting into when I use -compile(inline), so it might not even matter.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions


-- 
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham



More information about the erlang-questions mailing list