[erlang-questions] escript head mismatch error
Thu Feb 28 03:41:57 CET 2008
By ending your main/3 function with a semicolon, you're telling the
compiler that the next function is another function clause for main/3,
when in fact it's a completely different function (with a different
arity: (main/1) ) , hence the "head mismatch" error.
Semicolons are used as delimiters between function clauses with the
same name and arity. The main(_) -> usage() function is not another
main/3 function clause, although the semicolon at the end of main/3
tells the compiler to expect another main/3 clause. Replace the
semicolon in main/3 with a dot (.) and the "head mismatch" error
should go away.
See http://www.erlang.org/doc/reference_manual/functions.html#5 for
more details on Erlang function declaration syntax.
- Andy Gross
On Feb 27, 2008, at 8:54 PM, db wrote:
> Can someone tell me what's head mismatch error?
> ./rpc_test:17: head mismatch
> escript: There were compilation errors.
> Line 17 is this:
> main(_) ->
> My escript:
> #!/usr/bin/env escript
> %% -*- erlang -*-
> -export([main/3, main/1, main/2]).
> main(Node,Module,Args) ->
> rpc:call(Node, Module, main, Args)
> _:_ ->
> main(_) ->
> main(_,_) ->
> usage() ->
> io:format("usage: You need to provide valid Node Name & Module
> Name & Args\n"),
> thank you.
> That which we persist in doing becomes easier for us to do; not that
> the nature of the thing itself is changed, but that our power to do
> is increased.
> -Ralph Waldo Emerson _______________________________________________
> erlang-questions mailing list
More information about the erlang-questions