[erlang-questions] escript head mismatch error
Andy Gross
andy@REDACTED
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(_) ->
> usage()
>
>
> My escript:
> #!/usr/bin/env escript
> %% -*- erlang -*-
> %-mode(compile).
>
> -export([main/3, main/1, main/2]).
> %-export([main/3]).
>
> main(Node,Module,Args) ->
> try
> rpc:call(Node, Module, main, Args)
>
> catch
> _:_ ->
> usage()
> end;
>
> main(_) ->
> usage().
>
> main(_,_) ->
> usage().
>
> usage() ->
> io:format("usage: You need to provide valid Node Name & Module
> Name & Args\n"),
> halt(1).
>
>
> thank you.
> --
> rk
>
> 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
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list